navigation.navigate not working (not navigating to another screen)

I am using React Navigation 6, Expo 48, React Native 71.

I have tried using other functions like navigation.push() but no luck either. I also tried using getNavigation() instead of getting it from the props of the function but no luck either.

I’m not 100% sure if it navigation.navigate() is the problem since I didn’t get anything in the output.

In the following part of my code, everything runs except for navigation.navigate() in the “imTired” function.

  const imTired = (quiz) => {
    navigation2.navigate("Quiz", {
      host: index === 0 ? true : false,
      code: code,
      index: index,
      color: "#fff",
      qn: 15,
      comp: true,
      quiz: quiz,
    });
  };

  onSnapshot(doc(db, `Competitions/${code}`), (document) => {
    if (document.data().status === 1) {
      let quizz;
      quizzes.forEach((val, ind) => {
        if (val.Name === document.data().quiz) {
          quizz = val.Quiz;
        }
      });

      const quiz = [];
      const chosenIndexes = [];
      for (let i = 0; i < 17; i++) {
        let index = randomIntFromInterval(1, 51) - 1;

        if (chosenIndexes) {
          chosenIndexes.forEach((value, idx) => {
            while (value === index) {
              index = randomIntFromInterval(1, 51) - 1;
            }
          });
        }

        if (quizz[index].type === "multiple") {
          const rand = randomIntFromInterval(1, 3) - 1;
          const answers = [
            decode(quizz[index].incorrect_answers[0]),
            decode(quizz[index].incorrect_answers[1]),
          ];
          answers.splice(rand, 0, decode(quizz[index].correct_answer));
          quiz.push({
            qn: decode(quizz[index].question),
            q1: answers[0],
            q2: answers[1],
            q3: answers[2],
            ca: rand,
          });
        } else if (quizz[index].type === "boolean") {
          let caa;
          if (quizz[index].correct_answer === "True") {
            caa = 0;
          } else {
            caa = 1;
          }

          quiz.push({
            qn: decode(quizz[index].question),
            q1: "True",
            q2: "False",
            ca: caa,
          });
        }
      }
      imTired(quiz);
    }
  });