diff --git a/src/Expensify.tsx b/src/Expensify.tsx index ca9dec6d2279..8ec3fa194cf9 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -300,6 +300,7 @@ function Expensify({ authenticated={isAuthenticated} lastVisitedPath={lastVisitedPath as Route} initialUrl={initialUrl} + shouldShowRequire2FAModal={shouldShowRequire2FAModal} /> )} diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index e3ba198f0e30..225346cbff1a 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -224,7 +224,8 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie } if (!initialReportID) { - initialReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID)?.reportID; + const initialReport = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID); + initialReportID = initialReport?.reportID ?? ''; } isInitialRender.current = false; diff --git a/src/libs/Navigation/NavigationRoot.tsx b/src/libs/Navigation/NavigationRoot.tsx index 96e3413927a5..152594ba6b3e 100644 --- a/src/libs/Navigation/NavigationRoot.tsx +++ b/src/libs/Navigation/NavigationRoot.tsx @@ -39,6 +39,9 @@ type NavigationRootProps = { /** Fired when react-navigation is ready */ onReady: () => void; + + /** Flag to indicate if the require 2FA modal should be shown to the user */ + shouldShowRequire2FAModal: boolean; }; /** @@ -73,7 +76,7 @@ function parseAndLogRoute(state: NavigationState) { } } -function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: NavigationRootProps) { +function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady, shouldShowRequire2FAModal}: NavigationRootProps) { const firstRenderRef = useRef(true); const theme = useTheme(); const {cleanStaleScrollOffsets} = useContext(ScrollOffsetContext); @@ -94,7 +97,7 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N // If the user haven't completed the flow, we want to always redirect them to the onboarding flow. // We also make sure that the user is authenticated. - if (!hasCompletedGuidedSetupFlow && authenticated) { + if (!hasCompletedGuidedSetupFlow && authenticated && !shouldShowRequire2FAModal) { const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT.route, linkingConfig.config); return adaptedState; }