App icon indicating copy to clipboard operation
App copied to clipboard

[Exploratory] Account - Black screen flashes after enabling 2FA from forced setup flow

Open applause-bot[bot] opened this issue 1 month ago • 10 comments

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.27-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/tc/TC-179916 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: iOS 18.7.11 / iPhone XS / macOS 27.2 / Chrome 156 App Component: User Settings

Action Performed:

Preconditions:

  1. Log in as Admin on the mobile app or web.
  2. Navigate to Workspaces > Domains > applause2fa.expensifail > Domain Members.
  3. Search for the Member in the list and click the member row to open Settings.
  4. Click Reset two-factor authentication and confirm the reset.
  5. Attempt to log in as the Member account.
  6. Verify the member is redirected to the Two-factor authentication required setup flow.
  7. Complete the 2FA setup as the Member by entering the 2FA code.
  8. Observe the screen transition immediately after entering the 2FA code.

Expected Result:

The app should transition smoothly without any blank or black screen flashes after entering the 2FA code during forced setup.

Actual Result:

A black screen briefly appears after enabling 2FA when the user is redirected from the 2FA Required screen. This issue does not occur when 2FA is enabled directly from the user account.

Note: The issue is reproducible on both web and mobile, but is more noticeable on mobile. On the web, it appears as a brief flash, whereas on mobile, the screen turns completely black/blank for a couple of seconds before the 2FA success animation is displayed.

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/4c9a369f-0197-47eb-86b4-833da3683f3a

https://github.com/user-attachments/assets/aab6e1f1-2b63-42c9-84d7-6e84120d3ffb

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7301561

applause-bot[bot] avatar Nov 01 '26 21:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/4606a9e3418e2e74b329e93321b7e719c99f9d8632231a340575e779e10a8fcc

https://platform.applause.com/services/links/v1/external/b1f4f0135de2a8b0af76ada393d7b9ff90ab7f3715b98c597707168784b76cdf

applause-bot[bot] avatar Nov 01 '26 21:11 applause-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a user is forced to configure 2FA upon sign-in (e.g. after an admin resets their 2FA on an enforced domain, setting needsTwoFactorAuthSetup: true), entering the 2FA verification code causes the screen to flash black / blank for several seconds before the 2FA success screen appears.


What is the root cause of that problem?

In src/pages/settings/Security/TwoFactorAuth/ToggleTwoFactorAuthForm.tsx (line 38):

const shouldKeepTwoFactorAuthFlowOpen = AccountUtils.isForced2FAOnboardingSetup(account, !!hasCompletedGuidedSetupFlow);
const shouldClearData = (account?.needsTwoFactorAuthSetup ?? false) && !shouldKeepTwoFactorAuthFlowOpen;

For users who already completed guided setup (hasCompletedGuidedSetupFlow === true), shouldKeepTwoFactorAuthFlowOpen is false. When 2FA is forced via domain enforcement (account.needsTwoFactorAuthSetup === true), shouldClearData evaluates to true.

Then in src/libs/actions/Session/index.ts (lines 1548-1552):

// Clear onyx data if the user has just signed in and is forced to add 2FA
if (shouldClearData) {
    const keysToPreserveWithPrivatePersonalDetails = [...KEYS_TO_PRESERVE, ONYXKEYS.PRIVATE_PERSONAL_DETAILS];
    clearOnyxAndSeedFullReconnect(keysToPreserveWithPrivatePersonalDetails).then(() => updateAuthTokenAndOpenApp(response.authToken, response.encryptedAuthToken));
    return;
}
  1. clearOnyxAndSeedFullReconnect is called immediately upon OTP verification while the user is still on DynamicVerifyPage.
  2. This wipes all navigation, modal stack, and theme state in Onyx while waiting for updateAuthTokenAndOpenApp to reconnect.
  3. Because all screen data is cleared before DynamicSuccessPage is mounted, the entire React Native modal stack unmounts, revealing the root black/blank window background for 1–2 seconds until the full reconnect sequence restores state.
  4. Conversely, in the onboarding flow (lines 1519–1544), openApp() and Onyx cleanup are deferred until the user actually dismisses the success screen (DynamicSuccessPage), keeping IS_LOADING_APP: false and the 2FA flow mounted without flashing.

What changes do you think we should make in order to solve the problem?

De-escalate the disruptive mid-modal clearOnyxAndSeedFullReconnect when transitioning to DynamicSuccessPage:

  1. In src/libs/actions/Session/index.ts (validateTwoFactorAuth): Instead of wiping Onyx immediately while the user is viewing the 2FA modal, update the auth token and seed the verified 2FA account state while keeping the active modal mounted:
    if (shouldClearData) {
        updateAuthToken(response.authToken, response.encryptedAuthToken);
        Onyx.merge(ONYXKEYS.ACCOUNT, {
            requiresTwoFactorAuth: true,
            needsTwoFactorAuthSetup: false,
            isLoading: false,
            twoFactorAuthSecretKey: null,
        });
        return;
    }
    
  2. In src/pages/settings/Security/TwoFactorAuth/DynamicSuccessPage.tsx: Execute the full reconnect and openApp() on dismiss when account.needsTwoFactorAuthSetup was active, identical to the pattern used for onboarding in completeForcedOnboarding2FAHandoff().

This eliminates the unmount/remount cycle between DynamicVerifyPage and DynamicSuccessPage, completely removing the black screen flash.


What alternative solutions did you explore? (Optional)

Preserving [ONYXKEYS.IS_LOADING_APP]: true during clearOnyxAndSeedFullReconnect. This shows a spinner instead of a black screen, but still unmounts the modal before the user sees the success confirmation. Deferring the full reconnect to modal dismissal is the cleaner, seamless solution.


Automated Tests

Add a test in tests/unit/TwoFactorAuthTest.ts verifying that validateTwoFactorAuth preserves modal mounting state when shouldClearData is true.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01ca8ad8ce36b9eceb

apoorv-xs avatar Nov 01 '26 21:11 apoorv-xs

:warning: Unable to store contributor details

Details
Auth SetContributorDetails returned an error
401 Contributor details already exist

melvin-bot[bot] avatar Nov 01 '26 21:11 melvin-bot[bot]

Whoops! This issue is 2 days overdue. Let's get this updated quick!

melvin-bot[bot] avatar Nov 05 '26 00:11 melvin-bot[bot]

Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Nov 05 '26 02:11 melvin-bot[bot]

Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Nov 05 '26 03:11 melvin-bot[bot]

Eep! 4 days overdue now. Issues have feelings too...

melvin-bot[bot] avatar Nov 06 '26 21:11 melvin-bot[bot]

Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it!

melvin-bot[bot] avatar Nov 10 '26 21:11 melvin-bot[bot]

10 days overdue. I'm getting more depressed than Marvin.

melvin-bot[bot] avatar Nov 12 '26 21:11 melvin-bot[bot]

This issue has not been updated in over 14 days. eroding to Weekly issue.