Skip to content

[due for payment 2026-02-25] 2FA - App logs into Classic without showing 2FA screen after login #80226

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.6-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: #77588
Email or phone of affected tester (no customers): admin+220101@expplause.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Pixel 7 Pro /Android 16
App Component: User Settings

Action Performed:

Prerequisites:
Have a domain configured to require 2FA
Have a user on that domain who has not yet enabled two-factor auth
Step:

  1. Open the Hybrid app
  2. Sign in as the user who has not yet enabled 2fa

Expected Result:

Observe that the user sees the 2FA prompt immediately when they log in

Actual Result:

The app logs in directly to the Classic app without showing the 2FA screen.
The user is only prompted for 2FA after tapping Travel to switch to ND.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Activity

  1. added
    Daily
    Bug
    on Jan 22, 2026
  2. melvin-bot commented on Jan 22, 2026

    @melvin-bot

    Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. yatin-italy commented on Jan 22, 2026

    @yatin-italy

    Proposal

    Restate the problem this issue is trying to solve.

    Users on domains requiring 2FA can log in and access Classic without a 2FA prompt. The prompt only appears when navigating to NewDot, delaying enforcement.

    What is the root cause of that problem?

    signInToOldDotAndChooseExperience in src/libs/HybridApp.ts signs users into Classic (OldDot) without checking if 2FA is required. The 2FA check in src/libs/Navigation/NavigationRoot.tsx only sets initial navigation state for NewDot, and the check in src/hooks/useOnboardingFlow.ts runs in a delayed useEffect, so it cannot prevent the Classic sign-in.

    Invariant: Users requiring 2FA setup (needsTwoFactorAuthSetup && !requiresTwoFactorAuth) must complete 2FA before accessing Classic or NewDot.

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

    Add a 2FA check in signInToOldDotAndChooseExperience before signing into Classic. If 2FA is required, skip the Classic sign-in and show NewDot so the 2FA prompt can be displayed. Add an ACCOUNT Onyx callback to re-trigger the check when account data arrives.

    File: src/libs/HybridApp.ts

    • Add import for Account type
    • Add currentAccount variable
    • Add ACCOUNT Onyx connection that re-triggers the function
    • Add 2FA check in signInToOldDotAndChooseExperience before calling HybridAppModule.signInToOldDot()
    import HybridAppModule from '@expensify/react-native-hybrid-app';
    import Onyx from 'react-native-onyx';
    import type {OnyxEntry} from 'react-native-onyx';
    import CONFIG from '@src/CONFIG';
    import CONST from '@src/CONST';
    import ONYXKEYS from '@src/ONYXKEYS';
    import type {Account, Credentials, HybridApp, Session, TryNewDot} from '@src/types/onyx';
    import {isEmptyObject} from '@src/types/utils/EmptyObject';
    import {closeReactNativeApp, setReadyToShowAuthScreens, setUseNewDotSignInPage} from './actions/HybridApp';
    import Log from './Log';
    import {getCurrentUserEmail} from './Network/NetworkStore';
    
    function isAnonymousUser(sessionParam: OnyxEntry<Session>): boolean {
        return sessionParam?.authTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
    }
    
    let currentHybridApp: OnyxEntry<HybridApp>;
    let currentTryNewDot: OnyxEntry<TryNewDot>;
    let currentCredentials: OnyxEntry<Credentials>;
    let currentSession: OnyxEntry<Session>;
    let currentAccount: OnyxEntry<Account>;
    
    Onyx.connectWithoutView({
        key: ONYXKEYS.HYBRID_APP,
        callback: (hybridApp) => {
            currentHybridApp = hybridApp;
            signInToOldDotAndChooseExperience(hybridApp, currentTryNewDot, currentCredentials, currentSession);
        },
    });
    
    Onyx.connectWithoutView({
        key: ONYXKEYS.NVP_TRY_NEW_DOT,
        callback: (tryNewDot) => {
            currentTryNewDot = tryNewDot;
            signInToOldDotAndChooseExperience(currentHybridApp, tryNewDot, currentCredentials, currentSession);
        },
    });
    
    Onyx.connectWithoutView({
        key: ONYXKEYS.CREDENTIALS,
        callback: (credentials) => {
            currentCredentials = credentials;
            signInToOldDotAndChooseExperience(currentHybridApp, currentTryNewDot, credentials, currentSession);
        },
    });
    
    Onyx.connectWithoutView({
        key: ONYXKEYS.SESSION,
        callback: (session: OnyxEntry<Session>) => {
            currentSession = session;
            signInToOldDotAndChooseExperience(currentHybridApp, currentTryNewDot, currentCredentials, session);
        },
    });
    
    Onyx.connectWithoutView({
        key: ONYXKEYS.ACCOUNT,
        callback: (account) => {
            currentAccount = account;
            signInToOldDotAndChooseExperience(currentHybridApp, currentTryNewDot, currentCredentials, currentSession);
        },
    });
    
    let activePolicyID: OnyxEntry<string>;
    Onyx.connectWithoutView({
        key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
        callback: (newActivePolicyID) => {
            activePolicyID = newActivePolicyID;
        },
    });
    
    function shouldUseOldApp(tryNewDot: TryNewDot) {
        if (isEmptyObject(tryNewDot) || isEmptyObject(tryNewDot.classicRedirect)) {
            return true;
        }
        return tryNewDot.classicRedirect.dismissed;
    }
    
    /**
     * Signs the user into OldDot when session and credentials are available,
     * then decides whether to stay in NewDot or switch to OldDot based on `nvp_tryNewDot`.
     */
    function signInToOldDotAndChooseExperience(
        hybridApp: OnyxEntry<HybridApp>,
        tryNewDot: OnyxEntry<TryNewDot>,
        credentials: OnyxEntry<Credentials>,
        session: OnyxEntry<Session>,
    ) {
        if (!CONFIG.IS_HYBRID_APP) {
            return;
        }
    
        if (!session?.authToken || !hybridApp?.useNewDotSignInPage) {
            return;
        }
    
        if (isAnonymousUser(session)) {
            setReadyToShowAuthScreens(true);
            return;
        }
    
        if (!credentials?.autoGeneratedLogin || !credentials?.autoGeneratedPassword) {
            return;
        }
    
        // Skip if we're already in the signing in flow, preventing multiple calls to signInToOldDot
        if (session?.autoAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN) {
            return;
        }
    
        // Block sign-in to Classic if 2FA is required but not yet set up
        // This ensures users are shown the 2FA prompt in NewDot before accessing the app
        if (currentAccount?.needsTwoFactorAuthSetup && !currentAccount?.requiresTwoFactorAuth) {
            Log.info('[HybridApp] Blocking Classic sign-in because 2FA setup is required');
            setReadyToShowAuthScreens(true);
            return;
        }
    
        Log.info(`[HybridApp] Performing sign-in on OldDot side`);
        HybridAppModule.signInToOldDot({
            autoGeneratedLogin: credentials.autoGeneratedLogin,
            autoGeneratedPassword: credentials.autoGeneratedPassword,
            authToken: session.authToken,
            email: getCurrentUserEmail() ?? '',
            // eslint-disable-next-line rulesdir/no-default-id-values
            policyID: activePolicyID ?? '',
            signingInWithSAML: hybridApp?.signingInWithSAML ?? false,
        });
    
        if (tryNewDot !== undefined) {
            setUseNewDotSignInPage(false).then(() => {
                if (shouldUseOldApp(tryNewDot)) {
                    closeReactNativeApp({shouldSetNVP: false});
                } else {
                    setReadyToShowAuthScreens(true);
                }
            });
        }
    }

    What alternative solutions did you explore? (Optional)

    • Navigation or onboarding checks were too late because Classic sign-in already happened. Backend-only enforcement was heavier and did not fix the client timing issue.
  4. joekaufmanexpensify commented on Jan 22, 2026

    @joekaufmanexpensify
    Contributor
  5. chuckdries commented on Jan 22, 2026

    @chuckdries
    Contributor

    Hmmm, I wonder how long this hasn't worked. It repro's in prod so it's not new, and #77588 only touched ND code

  6. chuckdries commented on Jan 22, 2026

    @chuckdries
    Contributor

    After doing a little digging, it definitely looks like OldDot is supposed to have its own modal that says "Two Factor Authentication is required", so we shouldn't have to switch to NewDot just for that. I'm going to kick this over to expert contributors, because it requires knowledge of and access to Mobile-Expensify

  7. joekaufmanexpensify commented on Jan 26, 2026

    @joekaufmanexpensify
    Contributor

    I see. @chuckdries when you say expert do you mean a backend contributor? Since this is an issue for Expensify classic

  8. chuckdries commented on Jan 26, 2026

    @chuckdries
    Contributor

    I posted in #expert-contributors but nobody seemed interested

  9. added
    Hot Pick
    on Jan 26, 2026
  10. joekaufmanexpensify commented on Jan 29, 2026

    @joekaufmanexpensify
    Contributor

    Thanks!

  11. 19 remaining items

  12. joekaufmanexpensify commented on Feb 16, 2026

    @joekaufmanexpensify
    Contributor

    PR in review

  13. joekaufmanexpensify commented on Feb 23, 2026

    @joekaufmanexpensify
    Contributor

    PR out to prod on 18th, so due for payment in 2 days

  14. changed the title [-]2FA - App logs into Classic without showing 2FA screen after login[/-] [+][due for payment 2026-02-25] 2FA - App logs into Classic without showing 2FA screen after login[/+] on Feb 23, 2026
  15. added
    Awaiting Payment
    on Feb 23, 2026
  16. joekaufmanexpensify commented on Feb 23, 2026

    @joekaufmanexpensify
    Contributor

    @eVoloshchak could you please handle checklist here?

  17. eVoloshchak commented on Feb 25, 2026

    @eVoloshchak
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: N/A, this is the initial behavior

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: regression wasn't critical

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Have a domain configured to require 2FA
    • Have a user on that domain who has not yet enabled two-factor auth

    Test:

    1. Open the app
    2. Sign in as the user who has not yet enabled 2fa
    3. Verify you're redirected to set-up 2FA page on ND

    Do we agree 👍 or 👎

  18. joekaufmanexpensify commented on Feb 25, 2026

    @joekaufmanexpensify
    Contributor
  19. joekaufmanexpensify commented on Feb 25, 2026

    @joekaufmanexpensify
    Contributor

    All set to pay!

  20. joekaufmanexpensify commented on Feb 25, 2026

    @joekaufmanexpensify
    Contributor

    Payment Summary

  21. joekaufmanexpensify commented on Feb 25, 2026

    @joekaufmanexpensify
    Contributor

    @eVoloshchak please request payment at your earliest convenience. Closing as this is otherwise all set 👍

  22. trjExpensify commented on Mar 4, 2026

    @trjExpensify
    Contributor

    approved $250 for @eVoloshchak.

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyHot PickReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions