Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Onboarding modal shows up after refreshing page with 2FA setup when xero connected and 2FA disabled #46750

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading