Use usePrimaryContactMethod fallback on magic code pages after copilot switch#87711
Conversation
…ic code pages After switching back from a copilot account, account.primaryLogin is temporarily wiped by Onyx.clear in Delegate.disconnect(). This left the magic code email field blank on MissingPersonalDetailsMagicCodePage and MultifactorAuthentication ValidateCodePage. Replace direct account.primaryLogin reads with the existing usePrimaryContactMethod hook, which falls back to session.email (preserved through delegate switching). Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
@MelvinBot Mark this as ready for review |
|
🤖 I attempted to mark this PR as ready for review, but I don't have the required permissions to do so in this environment. Please mark it as ready for review manually using the GitHub UI or by running |
|
@MelvinBot Try again |
|
🤖 Done! This PR has been marked as ready for review. |
|
@ShridharGoel 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-04-13.at.12.19.05.AM.movAndroid: mWeb ChromeScreen.Recording.2026-04-13.at.12.15.12.AM.moviOS: mWeb SafariScreen.Recording.2026-04-13.at.12.11.53.AM.mov |
|
@MelvinBot Is this change needed in other places also like ReportCardLostConfirmMagicCodePage.tsx, ReportVirtualCardFraudVerifyAccountPage.tsx, and TravelCVVVerifyAccountPage.tsx ? |
|
Yes, all three files have the same vulnerable pattern (
|
|
@MelvinBot Ok then update them as well |
Replace account?.primaryLogin with usePrimaryContactMethod() in ReportCardLostConfirmMagicCodePage, ReportVirtualCardFraudVerifyAccountPage, and TravelCVVVerifyAccountPage to fix the same copilot-switch blank email issue. Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
Updated the three additional files to use
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot Fix it in ExpensifyCardVerifyAccountPage.tsx as well |
Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
Applied the same |
trjExpensify
left a comment
There was a problem hiding this comment.
Makes sense, weird one. 👍
|
🚧 @JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.59-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. The changes are purely internal — they replace how the primary email is sourced on magic code pages (switching from |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.3.59-4 🚀
|


Explanation of Change
After switching back from a copilot account,
Delegate.disconnect()callsOnyx.clear()which wipesONYXKEYS.ACCOUNT(includingprimaryLogin) before the asyncopenApp()response repopulates it. This left the email field blank on magic code pages that readaccount.primaryLoginwithout a fallback.This PR replaces direct
account.primaryLoginreads with the existingusePrimaryContactMethodhook in two affected pages. The hook falls back tosession.email, which is preserved through delegate switching viaKEYS_TO_PRESERVE_DELEGATE_ACCESS.Files changed:
MissingPersonalDetailsMagicCodePage.tsx— replaceduseOnyx(ONYXKEYS.ACCOUNT, {selector: primaryLoginSelector})withusePrimaryContactMethod()MultifactorAuthentication/ValidateCodePage.tsx— replacedaccount?.primaryLogin ?? ''withusePrimaryContactMethod()Fixed Issues
$ #87408
PROPOSAL: #87408 (comment)
Tests
Offline tests
N/A - The issue is caused by async Onyx state after copilot switching, not network state.
QA Steps
Same as tests above.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari