diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index 893ac21c64dc..ef3f7cddb987 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -345,7 +345,11 @@ function signIn(password, validateCode, twoFactorAuthCode, preferredLocale = CON API.write('SigninUser', params, {optimisticData, successData, failureData}); } -function signInWithValidateCode(accountID, validateCode, twoFactorAuthCode) { +function signInWithValidateCode(accountID, code, twoFactorAuthCode) { + // If this is called from the 2fa step, get the validateCode directly from onyx + // instead of the one passed from the component state because the state is changing when this method is called. + const validateCode = twoFactorAuthCode ? credentials.validateCode : code; + const optimisticData = [ { onyxMethod: CONST.ONYX.METHOD.MERGE,