Skip to content

[Payment due @huult] feat(wallet): prompt for magic code when changing wallet phone - #95566

Merged
rafecolton merged 14 commits into
Expensify:mainfrom
dukenv0307:fix/623849-wallet-magic-code
Jul 29, 2026
Merged

rafecolton merged 14 commits into
Expensify:mainfrom
dukenv0307:fix/623849-wallet-magic-code

Conversation

@dukenv0307

@dukenv0307 dukenv0307 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

In the wallet KYC personal-details step, when the user changes an existing phone number we now prompt for a magic code before submitting, and pass it as validateCode to UpdatePersonalDetailsForWallet. This protects the phone number used for card 3DS verification. If the code is missing or wrong, the backend returns an incorrectMagicCode error and the prompt stays open with the error shown; if the phone number is unchanged (or being set for the first time), no code is required.

Both wallet KYC flows that call UpdatePersonalDetailsForWallet are covered: the current Settings → Wallet flow (Wallet/PersonalInfo/PersonalInfo.tsx, prompt shown after the Confirmation substep) and the older IOU send-money flow (Pay/AdditionalDetails/AdditionalDetailsStep.tsx).

Related PRs (must deploy together): Auth https://github.com/Expensify/Auth/pull/22768 · Web-Expensify https://github.com/Expensify/Web-Expensify/pull/54357

Fixed Issues

$
For https://github.com/Expensify/Expensify/issues/623849
PROPOSAL: N/A (internal, backend-driven security fix)

Tests

Precondition:
Run https://github.com/Expensify/Auth/pull/22768 locally (build + restart)

Local dev setup notes:

  1. The dev magic code is always 000000 (hardcoded off-live).
  2. Wallet KYC auto-passes for the test identity Alberta Bobbeth Charleson, DOB 2000-08-08, SSN 123456789 (linked test bank: routing 011401533, checking 1111222233330000), so IDology is not hit.
  3. If you hit "There was an error resending the magic code", clear the resend throttle: DELETE FROM nameValuePairs WHERE name glob 'private_throttleAttempts_resendValidateCode*';

Manual:

The dev magic code is always 000000 (hardcoded off-live).
To pass wallet KYC without hitting IDology, use the test identity: Alberta Bobbeth Charleson, DOB 2000-08-08, SSN 123456789 (linked test bank: routing 011401533, checking 1111222233330000).

  1. As a test user with no wallet yet, go to Settings > Profile > Private personal details and save a phone number (e.g. a test US mobile number), confirming with magic code 000000 if prompted.
  2. Go to Settings > Wallet > Enable payments, add a bank account, and proceed to the Personal info step. Fill in Legal name/DOB/Address with the test KYC identity above, but enter a different phone number than the one saved in step 1, then SSN 123456789.
  3. On the Confirmation screen, tap "Confirm".
  4. Verify a magic code prompt appears; enter 000000 and verify the flow proceeds (e.g. to Verify identity) and the phone number is updated.
  5. Repeat step 3 entering an incorrect code (e.g. 111111) and verify the prompt stays open showing an error.
  6. Repeat the whole flow with a fresh test account that has no phone number saved anywhere, and verify magic code is required on that first-ever submission.
  • Verify that no errors appear in the JS console

Offline tests

  1. Repeat step 2-3 above while offline.
  2. Verify the magic code prompt still appears; the request is queued and processed once back online.

QA Steps

Assign to @dukenv0307, will test once Auth and App PRs are deployed

IMPORTANT: QA please be advised, it is expected that incorrect magic codes will be accepted in this flow until the BE changes are deployed.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-07-16.at.3.50.24.PM.mov
Screen.Recording.2026-07-16.at.3.50.53.PM.mov
Screen.Recording.2026-07-16.at.4.00.36.PM.mov

@dukenv0307
dukenv0307 requested review from a team as code owners July 8, 2026 10:10
@melvin-bot
melvin-bot Bot requested review from cead22 and trjExpensify and removed request for a team July 8, 2026 10:10
@melvin-bot

melvin-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

@cead22 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@dukenv0307
dukenv0307 marked this pull request as draft July 8, 2026 10:12
@dukenv0307
dukenv0307 marked this pull request as ready for review July 15, 2026 05:15
@codecov

codecov Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
src/ROUTES.ts 22.13% <100.00%> (+0.06%) ⬆️
src/SCREENS.ts 100.00% <ø> (ø)
...igation/linkingConfig/RELATIONS/SETTINGS_TO_RHP.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 66.66% <ø> (ø)
...s/EnablePayments/shared/useWalletPhoneMagicCode.ts 100.00% <100.00%> (ø)
...gation/AppNavigator/ModalStackNavigators/index.tsx 6.47% <0.00%> (-0.01%) ⬇️
...ts/Pay/AdditionalDetails/AdditionalDetailsStep.tsx 0.00% <0.00%> (ø)
...nablePayments/Wallet/PersonalInfo/PersonalInfo.tsx 0.00% <0.00%> (ø)
src/libs/actions/Wallet.ts 3.44% <0.00%> (-0.13%) ⬇️
... and 3 more
... and 12 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: deacc13204

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

trjExpensify
trjExpensify previously approved these changes Jul 15, 2026

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fire cleanup 👍

@jasperhuangg

Copy link
Copy Markdown
Contributor

@dukenv0307 took a look at your screen recording, and it doesn't appear to show us asking for the magic code at all. Am I missing something?

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@jasperhuangg My bad, I uploaded the wrong video. But I need to confirm 1 thing first:

  1. As a test user with no wallet yet, go to Settings > Profile > Private personal details and save a phone number (e.g. a test US mobile number), confirming with magic code 000000 if prompted.
  2. Go to Settings > Wallet > Enable payments, add a bank account, and proceed to the Personal info step. Fill in Legal name/DOB/Address with the test KYC identity above, but enter a same phone number as the one saved in step 1, then SSN 123456789.
  3. Press confirm

Should we show the prompt?

@jasperhuangg

Copy link
Copy Markdown
Contributor

@jasperhuangg My bad, I uploaded the wrong video. But I need to confirm 1 thing first:

  1. As a test user with no wallet yet, go to Settings > Profile > Private personal details and save a phone number (e.g. a test US mobile number), confirming with magic code 000000 if prompted.
  2. Go to Settings > Wallet > Enable payments, add a bank account, and proceed to the Personal info step. Fill in Legal name/DOB/Address with the test KYC identity above, but enter a same phone number as the one saved in step 1, then SSN 123456789.
  3. Press confirm

Should we show the prompt?

Yeah let's just always show the prompt, simpler logic. I imagine users will attempt to do that very rarely.

@huult huult left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Note: My native app build failed this time. I’ll update you once it’s done.

@huult

huult commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

LMK when y'all are ready for review 🙏

@rafecolton all yours

@melvin-bot melvin-bot Bot changed the title feat(wallet): prompt for magic code when changing wallet phone [Payment due @huult] feat(wallet): prompt for magic code when changing wallet phone Jul 23, 2026
@melvin-bot

melvin-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🎯 @huult, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - no internal issue.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

jasperhuangg
jasperhuangg previously approved these changes Jul 24, 2026
@huult

huult commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

cc @rafecolton

@rafecolton rafecolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should require a magic code any time a phone number is set, including if it was previously blank, not just if it is changed. Else you have this edge case:

  1. Admin issues a virtual card to a new user who has never set a phone number
  2. That user grants a bad actor access to their account (i.e. through social engineering) before the user ever viewed the virtual card details, so no phone number was set.
  3. Bad actor sets phone number for the first time through the wallet flow - no magic code.
  4. Bad actor gets the user to give them another code, this time to view the card details.

@dukenv0307

Copy link
Copy Markdown
Contributor Author

I fixed @rafecolton

Screen.Recording.2026-07-29.at.12.25.35.PM.mov

@rafecolton rafecolton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@rafecolton

Copy link
Copy Markdown
Member

Merging since Jasper previously approved and subsequent changes were minor

@rafecolton
rafecolton merged commit 9dc89de into Expensify:main Jul 29, 2026
34 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 rafecolton has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify OSBotify mentioned this pull request Jul 31, 2026
67 tasks done
@izarutskaya

Copy link
Copy Markdown

Hi @dukenv0307 Seems internal PR. Could you please check? thank you

QA Steps
Assign to @dukenv0307, will test once Auth and App PRs are deployed

IMPORTANT: QA please be advised, it is expected that incorrect magic codes will be accepted in this flow until the BE changes are deployed.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/rafecolton in version: 9.4.47-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — changes required ✅

This PR adds a magic code verification prompt to the wallet KYC (Enable payments) flow: when a user changes their phone number to one that differs from the one already saved, they must now confirm the change with a magic code before the personal details are submitted. No code is required when adding a phone number for the first time or leaving it unchanged.

This behavior happens during the Enter Personal Information step, which is documented in Set Up Your Wallet, so a doc update is warranted to reflect the new prompt.

Draft help site PR: #97545 — adds a note under Enter Personal Information describing the magic code verification (prompt titled Let's make sure it's you).

The other files in this PR (route/screen/navigation wiring, API param, shared components, tests) are internal implementation details with no user-facing surface beyond the prompt already covered above.


@dukenv0307, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review.

@OSBotify

OSBotify commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.4.47-7 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #97615

// code, SSN, or a generic failure) keeps the screen open to retry.
if (wasLoading.current && !hasErrors) {
wasLoading.current = false;
Navigation.navigate(ROUTES.SETTINGS_ENABLE_PAYMENTS.getRoute({page: CONST.ENABLE_PAYMENTS.PAGE_NAMES.VERIFY_IDENTITY}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #102336, navigation here always opens the Settings wallet identity page after the magic code is accepted. useWalletPhoneMagicCode is shared with the IOU pay flow (Pay/AdditionalDetails/AdditionalDetailsStep.tsx), so paying an IOU with a personal bank account lands here too.

The pay-flow page stays mounted underneath and also advances to Onfido from userWallet.currentStep. This page then mounts a second Onfido into the same #onfido-mount container. The SDK renders into the hidden screen, and the visible one stays blank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants