Repository navigation
Required 2FA setup screen is unresponsive, blocking new-domain login and account merge - #94486
Conversation
Unblock the Enable 2FA button for domain-migration users who must finish 2FA before guided setup by anchoring setup routes to Settings/Security, forcing the wizard path, pausing competing onboarding redirects, and cleanly handing off to onboarding after success.
Skip openApp() during validateTwoFactorAuth when setup runs during incomplete onboarding, so DynamicSuccessPage can complete the onboarding handoff after the user submits their authenticator code.
…-2fa-overlay-onboarding
|
@cretadn22 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] |
| clearTwoFactorAuthData(true); | ||
| Navigation.revealRouteBeforeDismissingModal(ROUTES.HOME, { | ||
| afterTransition: () => { | ||
| startOnboardingFlow({ |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
This startOnboardingFlow({...}) invocation builds the exact same 8-field params object (onboardingValuesParam, isUserFromPublicDomain, hasAccessiblePolicies, currentOnboardingCompanySize, currentOnboardingPurposeSelected, onboardingInitialPath, onboardingValues, isAccountValidated) from the same account/onboarding Onyx values that already exists in src/hooks/useOnboardingFlow.ts (lines 96-105). Duplicating this params-construction logic means any future change to how onboarding is started (new field, changed source value) must be made in two places, raising bug risk.
Extract the params construction into a shared helper (e.g. in @userActions/Welcome/OnboardingFlow) that derives the startOnboardingFlow params from account + onboarding values, and call it from both sites:
// OnboardingFlow.ts
function buildOnboardingFlowParams(account, onboardingValues, onboardingCompanySize, onboardingPurposeSelected, onboardingInitialPath) {
return {
onboardingValuesParam: onboardingValues ?? undefined,
isUserFromPublicDomain: !!account?.isFromPublicDomain,
hasAccessiblePolicies: !!account?.hasAccessibleDomainPolicies,
currentOnboardingCompanySize: onboardingCompanySize,
currentOnboardingPurposeSelected: onboardingPurposeSelected,
onboardingInitialPath,
onboardingValues,
isAccountValidated: !!account?.validated,
};
}
// Both call sites
startOnboardingFlow(buildOnboardingFlowParams(account, onboardingValues, onboardingCompanySize, onboardingPurposeSelected, onboardingInitialPath));Reviewed at: 121dfb7 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 121dfb76f8
ℹ️ 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".
| * (domain-migration / required-2FA-before-onboarding scenario). | ||
| */ | ||
| function isForced2FAOnboardingSetup(account: OnyxEntry<Account>, hasCompletedGuidedSetupFlow: boolean): boolean { | ||
| return !!account?.twoFactorAuthSetupInProgress && !hasCompletedGuidedSetupFlow; |
There was a problem hiding this comment.
Gate forced 2FA detection on required setup state
When a user can access the app without completing guided setup (for example invited/group-member accounts are explicitly skipped by useOnboardingFlow) and then enables 2FA from Settings, setCodesAreCopied() sets twoFactorAuthSetupInProgress to true. This helper will then classify that normal Settings flow as the forced domain-setup flow, causing ToggleTwoFactorAuthForm to skip the usual openApp/clear path and DynamicSuccessPage to send the user into onboarding instead of the enabled 2FA page. Please include the required-2FA condition in this predicate so ordinary unfinished-onboarding accounts are not redirected incorrectly.
Useful? React with 👍 / 👎.
Coerce hasCompletedGuidedSetupFlow to boolean in ToggleTwoFactorAuthForm and require requiresTwoFactorAuth in isForced2FAOnboardingSetup so voluntary Settings 2FA setup does not incorrectly trigger the onboarding handoff. Co-authored-by: Cursor <cursoragent@cursor.com>
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good for product
| // corrupts its dynamic base route, and flashes the overlay. Once 2FA finishes, the success page clears | ||
| // twoFactorAuthSetupInProgress and explicitly starts onboarding. | ||
| if (AccountUtils.shouldShowRequire2FAPage(account, !!isOnboardingCompleted)) { | ||
| Log.info('[Require2FA] Pausing onboarding redirect during required 2FA setup', false, { |
There was a problem hiding this comment.
I think we can leave out the log to keep things cleaner
| if (is2FAEnabled) { | ||
| const getTwoFactorAuthRoute = (backTo?: Route, options?: TwoFactorAuthRouteOptions): Route => { | ||
| if (is2FAEnabled && !options?.forceSetup) { | ||
| Log.info('[Require2FA] Resolved route to SETTINGS_2FA_ENABLED', false, { |
There was a problem hiding this comment.
We should get rid of all these new logs
|
Bug 1: When logging in, the onboarding flow initially starts with the "What's your work mail" screen. However, after completing the 2FA setup, the flow incorrectly skips ahead and displays the purpose selection screen. Bug 2: Upon completing the 2FA flow, the 2FA modal briefly flashes/appears for a moment before the onboarding flow is displayed. Screen.Recording.2026-06-30.at.22.10.15.mov |
|
@neerajbachani Please upload testing evidence for all platforms |
Resolve merge conflicts and fix required-2FA onboarding resume at work-email.
These files are unrelated to PR Expensify#94486 and break typecheck.
|
@cretadn22 Thanks for the review - addressed the bugs and cleaned up the branch. Bug 1 (resume wrong step → purpose instead of work-email)Root cause: Verified locally: work-email → required 2FA overlay → complete setup → resumes work-email (recording attached). Bug 2 (2FA modal flash before onboarding)Addressed by the existing handoff flow: pausing Testing evidenceScreen.Recording.2026-07-06.at.2.06.43.PM.online-video-cutter.com.1.mp4Merge / commit historyMerged latest |
Drop debug Log.info calls requested in review and update WorkEmailOnboarding tests for Fix C validated auto-nav guard during incomplete guided setup.
|
@codex review |
Empty commit to kick off a fresh CI run after self-hosted runner communication failures on the previous workflow run.
Empty commit to rerun workflows after self-hosted runner communication errors and cancelled Jest jobs on the previous CI run.
|
@iwiznia gentle bump, thanks |
|
🚧 iwiznia 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! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/iwiznia in version: 9.4.56-0 🚀
|
No help site changes required 📝I reviewed the changes in this PR and no updates to the help site ( Why: This PR is a bug fix that restores the intended behavior of the required‑2FA overlay for onboarding / domain‑migration users. It's entirely internal routing and navigation‑guard logic — no new user‑facing feature, setting, tab, button, or copy was introduced. Every change is in hooks, navigation guards, session/onboarding actions, and their tests; there are no new translation strings or labels. The existing article Two-Factor Authentication (2FA) already documents enabling 2FA and Domain Admins requiring it, and it remains accurate after this change — the documented steps (enable 2FA, save recovery codes, verify with an authenticator code) are unchanged. This PR just makes the "Two-factor authentication required" overlay's Enable two-factor authentication CTA reliably open the wizard again, which is the behavior the docs already assume. What changed in this PR
All are internal state/routing fixes with no accompanying UI copy or feature additions. @neerajbachani, since no user-facing behavior or copy changed, there's no help site PR to review here. If you believe a specific article should still be updated (e.g. to document the domain‑required 2FA onboarding flow in more detail), let me know which behavior you'd like documented and I'll draft it. |
|
Deploy Blocker #98938 was identified to be related to this PR. |
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.56-3 🚀
Bundle Size Analysis (Sentry): |
@joekaufmanexpensify Following up on our agreement to split the Sign out escape hatch into a follow-up PR (#94486 thread): the core #91985 fix is merged and the deploy blockers are resolved, so I’m ready to pick this back up. Could you please open a separate GitHub issue for the require-2FA overlay Sign out button and assign it to me? I already have the implementation prototyped locally (horizontal layout with Enable 2FA + Sign out, confirm modal same as Settings), once the issue is up I’ll open a small PR and loop in Design on placement if needed. |
|
Can we just use the existing issue? I would say it was intended to be fixed there. We just de-scoped it to get this PR done faster. |
|
This PR narrowed the early return in if (account?.validated) {
navigateToNextStep(account?.isFromPublicDomain);
return;
}to: if (account?.validated && hasCompletedGuidedSetupFlow) {
navigateToNextStep(account?.isFromPublicDomain);
return;
}This allowed the effect to fall through to the navigation at line ~108-111, which was the only Fixed in #101393. |
|
|
||
| const handleOnPress = () => { | ||
| snapshotOnboardingResumePathIfNeeded(); | ||
| Navigation.navigate(getTwoFactorAuthRoute(ROUTES.SETTINGS_SECURITY, {forceSetup: true})); |
There was a problem hiding this comment.
Coming from #101848.
This line gave the require-2FA overlay the same ROUTES.SETTINGS_SECURITY base as voluntary setup from Settings > Security.
The onboarding handoff in DynamicSuccessPage only runs for users who haven't finished onboarding. An invited admin who has finished onboarding went down the voluntary branch from #92637 instead.
After Got it, they stayed on Account > Security rather than landing on Home. Before this PR, setup ran on top of the active route, so those admins went back to Home.
Fixed in #102482.
Explanation of Change
Fixes the required-2FA overlay blocking domain-migration / incomplete-onboarding users from completing 2FA setup.
When
twoFactorAuthSetupInProgressis true during incomplete guided setup, the overlay CTA could not reliably open the 2FA wizard: the dynamic route was anchored to the onboarding screen behind the overlay,requiresTwoFactorAuth: truerouted to the enabled page (which does not dismiss the overlay), the wizard bounced back to the enabled page,OnboardingGuardanduseOnboardingFlowfought the 2FA modal, and submitting the authenticator code calledopenApp()before the success page could restart onboarding.This PR:
ROUTES.SETTINGS_SECURITYwithforceSetup: trueOnboardingGuardDynamicSuccessPageopenApp()onvalidateTwoFactorAuthduring forced onboarding 2FA setup so the verify → success → onboarding path worksFixed Issues
$ #91985
PROPOSAL: #91985 (comment)
Tests
Offline tests
Same as Tests — this flow is routing/UI state driven and does not require additional offline-specific steps beyond verifying no console errors while offline after setup completes.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, 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.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-2fa.online-video-cutter.com.mp4
Android: mWeb Chrome
androi-web-2fa.online-video-cutter.com.mp4
iOS: Native
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-07-27.at.00.online-video-cutter.com.1.mp4
iOS: mWeb Safari
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-07-27.at.00.online-video-cutter.com.mp4
MacOS: Chrome / Safari
Screen.Recording.2026-07-06.at.2.06.43.PM.online-video-cutter.com.1.mp4