Skip to content

Commit

Permalink
Merge pull request #46750 from tushar-a-b/fix/46026
Browse files Browse the repository at this point in the history
Fix: Onboarding modal shows up after refreshing page with 2FA setup when xero connected and 2FA disabled
  • Loading branch information
Julesssss authored Aug 6, 2024
2 parents 3775dae + 0047ab6 commit 290a9d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ function Expensify({
authenticated={isAuthenticated}
lastVisitedPath={lastVisitedPath as Route}
initialUrl={initialUrl}
shouldShowRequire2FAModal={shouldShowRequire2FAModal}
/>
</SplashScreenHiddenContext.Provider>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit 290a9d9

Please sign in to comment.