From cf51c7ff7e0bf91fe31af0416dfc7a95e70ba055 Mon Sep 17 00:00:00 2001 From: Tushar Date: Fri, 2 Aug 2024 13:27:43 -0400 Subject: [PATCH 1/2] fix onboarding modal shows up after refreshing page with 2FA setup when xero connected and 2FA disabled --- src/Expensify.tsx | 1 + src/libs/Navigation/AppNavigator/AuthScreens.tsx | 3 ++- src/libs/Navigation/NavigationRoot.tsx | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) 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..0fbcc9fdd748 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; } From 0047ab6662f99e494e4bffac265723ee7d54e945 Mon Sep 17 00:00:00 2001 From: Tushar Date: Mon, 5 Aug 2024 12:44:05 -0400 Subject: [PATCH 2/2] resolve lint error --- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 0fbcc9fdd748..225346cbff1a 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -225,7 +225,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie if (!initialReportID) { const initialReport = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID); - initialReportID = initialReport?.reportID ?? ""; + initialReportID = initialReport?.reportID ?? ''; } isInitialRender.current = false;