AWS Amplify: EmptyChallengeResponse Error when confirming sign-in with new password

I’m encountering the following error when trying to confirm a sign-in with a new password in aws-amplify V6:

Error:

EmptyChallengeResponse: challengeResponse is required to confirmSignIn

Here’s the relevant code snippet:

const handleSubmit = async (e) => {
    e.preventDefault();
  
    try {
      if (!requireNewPassword) {
        console.log("[] username", username);
        console.log("[] password", password);
        const signInResponse = await signIn({
          username,
          password,
          options: {
            authFlowType: "ALLOW_USER_PASSWORD_AUTH"
          }
        });
        console.log("[] signInResponse", signInResponse);
  
        if (signInResponse.nextStep.signInStep === "CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED") {
          console.log("CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED");
  
          const newPassword = prompt("Please enter your new password:");
          if (newPassword) {
            const challengeResponse = signInResponse;
            if (challengeResponse) {
              const confirmSignInResponse = await confirmSignIn(
                challengeResponse,
                newPassword,
                "ALLOW_USER_PASSWORD_AUTH"
              );
              console.log("[] user after password change", confirmSignInResponse);
              navigate("/dashboard");
            } else {
              console.error("Challenge response not found.");
            }
          }
  
          setUser(signInResponse);
          setRequireNewPassword(true);
        } else {
          navigate("/dashboard");
        }
      } else {
        const confirmSignInResponse = await confirmSignIn(
          user,
          newPassword,
          "NEW_PASSWORD_REQUIRED"
        );
        console.log("[] user after password change", confirmSignInResponse);
        navigate("/dashboard");
      }
    } catch (error) {
      setError("Invalid username or password");
      console.error("Error:", error);
    }
  };

I am not really sure where the chalange response should be or what is it