Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: v9.4.84-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/74548906/folder/52723519/96645709/1771054333?sort=%2Bidentifier
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Android 16 / Honor x6b
App Component: User Settings
Action Performed:
Precondition: Device must have a system-level Screen Lock (PIN/Pattern) and Biometrics (Fingerprint or FaceID)
- Open the Expensify app
- Tap the screen with 4 fingers simultaneously to bring up the hidden Test Tool menu
- Locate Biometrics row
- Tab "Test" button
- Enter the incorrect Magic Code
- Verify the error appears
Result: Any error is shown, user is redirected to Verification fail screen - Verify the Didn't receive magic code? status message appear
Result: as user is redirected to fail screen user need to iniciate the requeste instead or ask for another magic code
Expected Result:
The user should be able to request a new Magic Code and continue the verification process, after tapping “Didn’t receive magic code?”
Actual Result:
After entering an incorrect Magic Code, the user is redirected to the Verification Failed screen. The user remains on the failure flow and must initiate the Magic Code request again instead of being able to directly request another code.
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome Safari
Screenshots/Videos
Bug7262839_1789693097033.video_ok.mp4
Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7262839
Issue Owner
Current Issue Owner: @mallenexpensifyUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022105255723061936533
- Upwork Job ID: 2105255723061936533
- Last Price Increase: 2026-09-30
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
applause-bot commentedon Sep 18, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/23cc963a668354bd10bfe0b7ee544fdfe1aabaa4790859f3921f1f44080a686c
MelvinBot commentedon Sep 18, 2026
Proposal
What is the root cause of that problem?
An invalid magic code is supposed to be a continuable error that keeps the user on the magic code screen. That classification is failing, so the flow is treated as fatal and pushed to the "Verification failed" outcome screen.
The intended path is:
src/libs/MultifactorAuthentication/shared/helpers.ts:85resolves the API response to areason.CLIENT_ERRORS.INVALID_VALIDATE_CODE, the reducer stores it ascontinuableErrorand leaveserrorundefined —stateReducer.ts:45-50.process()then short-circuits oncontinuableErrorand the user stays put —MultifactorAuthenticationMainContext.tsx:195— with the inline "Incorrect or invalid security code" message atValidateCodePage.tsx:83-86.Step 1 is the weak link. The reason is derived by string-matching the free-text API message:
helpers.ts:46-50doeslowerMessage.endsWith('invalid validate code'). If the message does not end with that exact phrase, the match misses andgetFallbackReasonreturnsCLIENT_ERRORS.UNRECOGNIZED. That is a normal (non-continuable)error, soprocess()callshandleCallback(false)and navigates to the failure outcome —MultifactorAuthenticationMainContext.tsx:199-211and:162-163.The specific screen reported corroborates this. "Verification failed" is
DefaultClientFailureScreen(defaultScreens.tsx:10-21), which only renders for a 4xx-derived reason. So the 4xx did arrive — it just was not recognised as "invalid validate code".What changes do you think we should make in order to solve the problem?
Stop depending on an exact-suffix match of a free-text message to decide whether the flow can continue.
resolveReason/findReasonByBackendMessage(helpers.ts:46-69), match on a substring (and trim punctuation) rather thanendsWith, so wording or trailing-punctuation drift cannot silently reclassify a recoverable error as fatal.REQUEST_AUTHENTICATION_CHALLENGEwhile a user-enteredvalidateCodeis in flight should default toCLIENT_ERRORS.INVALID_VALIDATE_CODE, notUNRECOGNIZED. Failing back to "let the user retype the code" is strictly safer than dead-ending the flow.INVALID_VALIDATE_CODEappears in no test undertests/), which is why the regression reached staging.Secondary issue, same test case (step 7). Even when the continuable path works, the resend link is not immediately available:
ValidateCodeResendButton.tsx:41starts withisCountdownRunning = trueand only swaps in the "Request a new code" text after the countdown ends (:75). After an incorrect code we should show the resend link right away instead of making the user wait out the timer.What alternative solutions did you explore? (Optional)
Alternatives considered and ruled out
ValidateCodePage.tsx:92-101promotes acontinuableErrorto a fatal one if the reason is notINVALID_VALIDATE_CODE. Ruled out: the reducer only ever populatescontinuableErrorfor that exact reason, so this branch is unreachable today.continuableErroris deliberately absent from the effect deps atMultifactorAuthenticationMainContext.tsx:429-450. I traced submit → error → retype → resubmit and the flow recovers correctly, so this is not the cause. It does mean resubmitting the identical code is a no-op, which is a separate minor wart.SERVER_ERRORS/UNHANDLED_API_RESPONSEreason. Ruled out by the reported screen: those route toDefaultServerFailureScreen("Oops"), not "Verification failed" (OutcomePage.tsx).Confidence: medium. The chain from "reason resolves to
UNRECOGNIZED" → failure screen is confirmed in code. The one link I could not verify is why the match misses — that needs the actual API response message for an invalid code on the registration challenge call, which lives outside this repo. If the wording there changed recently, that is a backend-side regression and needs an internal engineer to confirm; the hardening in changes 1–3 is worth doing either way, since App should never dead-end a recoverable flow because a message string drifted.How to confirm quickly: reproduce on staging and check the
Flow errorSentry breadcrumb (MultifactorAuthenticationMainContext.tsx:208) — it logs bothreasonand the rawmessage. IfreasonisClient: Unrecognized client error, this diagnosis is confirmed andmessageshows the exact string to match against.Possibly related
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/101508)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
melvin-bot commentedon Sep 18, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (
External)melvin-bot commentedon Sep 18, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
[-]Mobile Biometrics- Enter incorrect Magic Code redirect to verification failed screen[/-][+]Mobile Biometrics - Enter incorrect Magic Code redirect to verification failed screen[/+]suneox commentedon Sep 21, 2026
I'll take a look at this one today
suneox commentedon Sep 24, 2026
@MelvinBot Currently the RequestAuthenticationChallenge API response returns
{ "jsonCode": 401, "message": "401 Not authorized - Invalid validateCode", "source": "auth-via-api", "onyxData": [], "requestID": "a3fff9b87c890dbe-SIN" }We have a mismatch with BACKEND_MESSAGE.INVALID_VALIDATE_CODE, let's analyze & update the proposal
MelvinBot commentedon Sep 24, 2026
Proposal
Updated:
suneoxis right — the mismatch is the whole bug, and it is narrower than my first proposal claimed. Corrected below.What is the root cause of that problem?
The App's copy of the backend message is misspelled, so an invalid magic code is never recognised as recoverable.
Invalid validate code— three words (VALUES.ts:12)Invalid validateCode— one camelCase wordBoth sides are lowercased before comparing (
helpers.ts:47), so the casing is irrelevant. The only difference that matters is the extra space.'401 not authorized - invalid validatecode'.endsWith('invalid validate code')isfalse, so the lookup misses, and the flow falls back toCLIENT_ERRORS.UNRECOGNIZED(helpers.ts:27-30) — a fatal error rather than a continuable one (stateReducer.ts:47-50) — and the user is sent to "Verification failed".Two corrections to my earlier proposal:
endsWithis not the bug. It works correctly forRegistration required, becauseendsWithonly needs an exact suffix and the backend's401 Not authorized -/400prefix does not interfere. The defect is purely the wrong constant value.INVALID_VALIDATE_CODE" suggestion. See alternatives — it is actively unsafe.Why "Verification failed" specifically, and why it's a hard dead-end
UNRECOGNIZEDis notREGISTRATION_REQUIRED, soprocess()callshandleCallback(false)(MultifactorAuthenticationMainContext.tsx:200-211), which navigates toOUTCOME_FAILURE(:162-163) →DefaultClientFailureScreen(defaultScreens.tsx:10-21).Navigation uses
StackActions.replace(mfaNavigation.ts:69), so the magic-code route is destroyed rather than pushed over. There is no back target and the outcome screen's only control closes the modal — which is exactly the "must start over" behaviour in the report.Independent confirmation of the backend string, from App itself:
CONST/index.ts:7145already hard-codes'401 Not authorized - Invalid validateCode'and compares it with strict===atSession/index.ts:1822;AccountValidatePage.tsx:77matches the same camelCase form. The three-word spelling appears nowhere insrc/as a wire string — only in this constant and two comments.What changes do you think we should make in order to solve the problem?
Correct the constant at
VALUES.ts:12to the camelCase spelling the backend actually sends. Blast radius is two map keys — it is read only atVALUES.ts:102and:107, and nothing else insrc/ortests/reads it.Do not also change
VALUES.ts:30. That is an internal reason token compared by identity in the reducer and inROUTINE_FAILURES; it never touches the wire.Add the regression test that would have caught this.
helpers.test.tshas 11 cases, and every message-matching assertion usesRegistration required— the one constant that already worked. Assert that a 401 with the realRequestAuthenticationChallengemessage resolves toCLIENT_ERRORS.INVALID_VALIDATE_CODE. This is the highest-value part of the change.Optional hardening: normalize the message before matching — trim and strip trailing punctuation — keeping
endsWith. Today a trailing period or any appended detail would silently reintroduce this exact bug. Prefer this over switching toincludes(reasoning in alternatives).Remove the dead mapping at
VALUES.ts:107.RegisterAuthenticationKeycannot produce this error: it sends onlykeyInfo(actions/MultifactorAuthentication/index.ts:77-79) and its parameter type explicitlyOmitsvalidateCode(config/types.ts:168-176).validateCodeis only ever sent onRequestAuthenticationChallenge.Heads up: step 7 of the repro is a second, separate bug
Fixing the above will expose it rather than fix it. The resend link starts hidden behind a 30-second countdown —
isCountdownRunningis initialised totrue(ValidateCodeResendButton.tsx:41) and the pressable is not rendered at all while it runs (:57), anchored to component mount withCONST.REQUEST_CODE_DELAY = 30(CONST/index.ts:1548). So a user who enters a wrong code within the first 30 seconds sees the inline error but has no way to request a new code until the timer expires. It is a bounded 0-30s gap, not permanent.Worth deciding whether to fold into this issue or split: reveal the pressable whenever
hasErroris true regardless of the countdown, or seed the countdown from a realrequestedAt.What alternative solutions did you explore? (Optional)
Rejected: switch the matcher to
includesTempting, and it would survive trailing punctuation — but it converts a loud unknown error into a confidently-wrong handler. A backend message that merely mentions a mapped phrase would match, and
Registration requireddrives the destructiveclearLocalMFAPublicKeyList()+ re-register path (MultifactorAuthenticationMainContext.tsx:201-205). Normalizing punctuation fixes the same fragility with none of that risk.Worth noting either way: no current mapped message is a substring of any other, so there is no cross-matching today. But
Object.entries(...).find(...)is first-match-wins in declaration order, so if that ever changed, the order of the entries inVALUES.tswould silently decide the outcome.Rejected (withdrawn from my first proposal): default a 4xx on a validateCode request to INVALID_VALIDATE_CODE
Two concrete hazards:
Registration requiredalso arrives as a 4xx on the same registration-challenge request. If its explicit match ever failed — the exact failure mode we are fixing — the fallback would swallow it and break re-registration recovery.ANOMALOUS_FAILURESintoROUTINE_FAILURES, downgrading the Sentry log level fromerrortoinfoand hiding future breakage.If a safety net is still wanted, the correct shape is the inverse: make
CLIENT_ERRORS.UNRECOGNIZEDnon-fatal while the user is on the validate-code screen, so they keep the retry and resend affordances instead of being replaced out to the outcome screen. That is a larger design change and belongs in a follow-up, not this fix.Ruled out: stale-state race, and the page-level error conversion
continuableErroris deliberately absent from the effect deps (MultifactorAuthenticationMainContext.tsx:429-450). Traced submit → error → retype → resubmit; the flow recovers correctly. Not the cause.ValidateCodePage.tsx:92-101promotes a non-INVALID_VALIDATE_CODEcontinuable error back to fatal. Unreachable — the reducer only ever populatescontinuableErrorfor that one reason.Confidence: high. The mismatch is deterministic and the chain from it to "Verification failed" is confirmed in code. The backend string is corroborated three ways: the response
suneoxposted above, and two existing App call sites that already match the camelCase form (one with strict equality).Possibly related: [ECUK In-App 3DS] [App] Refactor MultifactorAuthenticationContextProvider - fix React rules violations and race conditions risks — tracking issue for the state machine that drives this flow. Not a duplicate, but a fix here should be aware of it.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/101508)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
suneox commentedon Sep 24, 2026
Correcting the invalid constant is a straightforward fix for this issue, the same check used in AccountValidatePage
@MelvinBot implement this (#101508 (comment)) skip change
#3 optional hardening🎀 👀 🎀 C+ reviewed
23 remaining items
melvin-bot commentedon Oct 7, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 7, 2026
Payment Summary
Resolving PRs:
Match the backend Invalid validateCode message so a wrong magic code stays retryable #102137
Reviewer: @suneox owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
melvin-bot commentedon Oct 12, 2026
@mallenexpensify Eep! 4 days overdue now. Issues have feelings too...
mallenexpensify commentedon Oct 14, 2026
Payment Summary
Contributor+: @suneox due $250 via NewDot
garrettmknight commentedon Oct 19, 2026
$250 approved for @suneox