You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-03-19] [$250] Web - Login - 2nd tab change to Magic code expired page after enter incorrect 2FA code #79647
Please re-state the problem that we are trying to solve in this issue.
When a user opens a magic link in one tab and then opens a second tab to the same staging URL, if they enter an incorrect 2FA code in the first tab, the second tab unexpectedly changes to show "Magic code expired" instead of remaining on the 2FA authentication page.
What is the root cause of that problem?
The autoAuthState is stored in ONYXKEYS.SESSION which is shared across browser tabs via Onyx. When the 2FA validation fails in Tab 1, the signInWithValidateCode function sets autoAuthState: CONST.AUTO_AUTH_STATE.FAILED in its failureData:
This FAILED state propagates to Tab 2 through Onyx. In ValidateLoginPage/index.website.tsx, the component unconditionally shows ExpiredValidateCodeModal whenever autoAuthState === FAILED:
But these are semantically different errors. If account.requiresTwoFactorAuth is true, it means the magic code was already validated successfully - the user progressed to the 2FA step. A 2FA failure should not trigger "magic code expired".
What changes do you think we should make in order to solve the problem?
The is2FARequired variable is already computed on line 33 from account?.requiresTwoFactorAuth. When 2FA is required, the magic code was valid, so showing "magic code expired" is incorrect regardless of what caused the FAILED state.
What alternative solutions did you explore? (Optional)
Adding a separate AUTO_AUTH_STATE for 2FA failures would work but is more invasive. The existing is2FARequired flag already provides the information needed to distinguish between magic code failures and 2FA failures.
Please re-state the problem that we are trying to solve in this issue.
When a user enters an incorrect two-factor authentication code during magic link sign-in, they see the "Magic code
expired" modal. This is misleading because the magic code isn't expired — the 2FA code was simply wrong.
What is the root cause of that problem?
The signInWithValidateCode function sets autoAuthState to FAILED on any failure, without distinguishing between an expired
magic link and a failed 2FA attempt:
expiredCodeDescription: 'Go back to the original device and request a new code',
twoFactorAuthFailedTitle: 'Invalid two-factor authentication code',
twoFactorAuthFailedDescription: 'The two-factor authentication code you entered is incorrect. Please try again.',
Create a new TwoFactorAuthFailedModal component in src/components/ValidateCode/ with the same layout as
ExpiredValidateCodeModal but using the new translation keys. Alternatively, we could make the ExpiredValidateCodeModal take some props and reuse the component and change its name.
changed the title [-]Web - Login - 2nd tab change to Magic code expired page after enter incorrect 2FA code[/-][+][$250] Web - Login - 2nd tab change to Magic code expired page after enter incorrect 2FA code[/+]on Jan 15, 2026
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: NA
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Test:
Open the app and start signing in to the account where 2FA is enabled.
Navigate to the email and locate the magic link
Open the magic link in a new tab
In the first tab, enter an incorrect 2FA code
Switch to the second tab
Verify the second tab still shows the 2FA required page and does NOT show "Magic code expired" or an empty page
Activity
melvin-bot commentedon Jan 15, 2026
Triggered auto assignment to @twisterdotcom (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.MobileMage commentedon Jan 15, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user opens a magic link in one tab and then opens a second tab to the same staging URL, if they enter an incorrect 2FA code in the first tab, the second tab unexpectedly changes to show "Magic code expired" instead of remaining on the 2FA authentication page.
What is the root cause of that problem?
The
autoAuthStateis stored inONYXKEYS.SESSIONwhich is shared across browser tabs via Onyx. When the 2FA validation fails in Tab 1, thesignInWithValidateCodefunction setsautoAuthState: CONST.AUTO_AUTH_STATE.FAILEDin itsfailureData:App/src/libs/actions/Session/index.ts
Lines 830 to 844 in 5f419d2
This
FAILEDstate propagates to Tab 2 through Onyx. InValidateLoginPage/index.website.tsx, the component unconditionally showsExpiredValidateCodeModalwheneverautoAuthState === FAILED:App/src/pages/ValidateLoginPage/index.website.tsx
Line 79 in 5f419d2
The problem is that
FAILEDis used for both:But these are semantically different errors. If
account.requiresTwoFactorAuthis true, it means the magic code was already validated successfully - the user progressed to the 2FA step. A 2FA failure should not trigger "magic code expired".What changes do you think we should make in order to solve the problem?
On line 79 of ValidateLoginPage/index.website.tsx, add a condition to only show
ExpiredValidateCodeModalwhenis2FARequiredis false:Change from:
To:
The
is2FARequiredvariable is already computed on line 33 fromaccount?.requiresTwoFactorAuth. When 2FA is required, the magic code was valid, so showing "magic code expired" is incorrect regardless of what caused theFAILEDstate.What alternative solutions did you explore? (Optional)
Adding a separate
AUTO_AUTH_STATEfor 2FA failures would work but is more invasive. The existingis2FARequiredflag already provides the information needed to distinguish between magic code failures and 2FA failures.imadirtydog commentedon Jan 15, 2026
Please re-state the problem that we are trying to solve in this issue.
When a user enters an incorrect two-factor authentication code during magic link sign-in, they see the "Magic code
expired" modal. This is misleading because the magic code isn't expired — the 2FA code was simply wrong.
What is the root cause of that problem?
The signInWithValidateCode function sets autoAuthState to FAILED on any failure, without distinguishing between an expired
magic link and a failed 2FA attempt:
App/src/libs/actions/Session/index.ts
Lines 834 to 838 in 728784e
The ValidateLoginPage then renders ExpiredValidateCodeModal for any FAILED state:
https://github.com/Expensify/App/blob/728784e0312b0bef5a0099f0f92fc746199de50c/src/pages/ValidateLoginPage/index.website.t
sx#L79
There is no separate state to represent a 2FA-specific failure, so both cases show the same expired code message.
What changes do you think we should make in order to solve the problem?
Add a new TWO_FACTOR_AUTH_FAILED value to CONST.AUTO_AUTH_STATE in src/CONST/index.ts:
App/src/CONST/index.ts
Lines 293 to 298 in 728784e
AUTO_AUTH_STATE: {
NOT_STARTED: 'not-started',
SIGNING_IN: 'signing-in',
JUST_SIGNED_IN: 'just-signed-in',
FAILED: 'failed',
TWO_FACTOR_AUTH_FAILED: 'two-factor-auth-failed',
},
In signInWithValidateCode in src/libs/actions/Session/index.ts, conditionally set the failure state based on whether a
twoFactorAuthCode was provided:
App/src/libs/actions/Session/index.ts
Lines 834 to 838 in 728784e
value: {autoAuthState: twoFactorAuthCode
? CONST.AUTO_AUTH_STATE.TWO_FACTOR_AUTH_FAILED
: CONST.AUTO_AUTH_STATE.FAILED},
App/src/languages/en.ts
Lines 767 to 768 in 728784e
twoFactorAuthFailedTitle: 'Invalid two-factor authentication code',
twoFactorAuthFailedDescription: 'The two-factor authentication code you entered is incorrect. Please try again.',
ExpiredValidateCodeModal but using the new translation keys. Alternatively, we could make the ExpiredValidateCodeModal take some props and reuse the component and change its name.
https://github.com/Expensify/App/blob/728784e0312b0bef5a0099f0f92fc746199de50c/src/pages/ValidateLoginPage/index.website.t
sx#L79
{autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.FAILED && }
{autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.TWO_FACTOR_AUTH_FAILED && }
[-]Web - Login - 2nd tab change to Magic code expired page after enter incorrect 2FA code[/-][+][$250] Web - Login - 2nd tab change to Magic code expired page after enter incorrect 2FA code[/+]melvin-bot commentedon Jan 15, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022011939480797251822
melvin-bot commentedon Jan 15, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (
External)melvin-bot commentedon Jan 21, 2026
@shubham1206agra Eep! 4 days overdue now. Issues have feelings too...
melvin-bot commentedon Jan 22, 2026
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
56 remaining items
melvin-bot commentedon Mar 12, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)mallenexpensify commentedon Mar 20, 2026
Payment Summary
Contributor: @MobileMage paid $250 via Upwork
Contributor+: @shubham1206agra due $250 via NewDot
@shubham1206agra plz complete the BZ checklist and tag me in a post once you have. Thx
melvin-bot commentedon Mar 23, 2026
@mallenexpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Mar 23, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
cristipaval commentedon Mar 24, 2026
bump @shubham1206agra
shubham1206agra commentedon Mar 26, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: https://github.com/Expensify/App/pull/15505/changes#r2992249470
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: NA
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Test:
Do we agree 👍 or 👎
shubham1206agra commentedon Mar 26, 2026
@mallenexpensify You can close this issue now
garrettmknight commentedon Apr 2, 2026
$250 approved for @shubham1206agra