@@ -34,6 +34,23 @@ const getRoutesWithIndex = (routes: NavigationPartialRoute[]): PartialState<Navi
3434/** All tab routes derived from the shared TAB_SCREENS constant. */
3535const TAB_NAVIGATOR_ROUTES : NavigationPartialRoute [ ] = TAB_SCREENS . map ( ( name ) => ( { name} ) ) ;
3636
37+ /**
38+ * Screens that are registered in PublicScreens (unauthenticated navigator) and should not
39+ * have TabNavigator prepended, because when the user is unauthenticated TabNavigator does
40+ * not exist in the navigator tree and the RESET action would fail.
41+ *
42+ * Keep in sync with the screens registered in PublicScreens.tsx (excluding SCREENS.HOME,
43+ * which doubles as the authenticated home tab, and navigator entries).
44+ */
45+ const PUBLIC_SCREENS = new Set < string > ( [
46+ SCREENS . VALIDATE_LOGIN ,
47+ SCREENS . TRANSITION_BETWEEN_APPS ,
48+ SCREENS . CONNECTION_COMPLETE ,
49+ SCREENS . BANK_CONNECTION_COMPLETE ,
50+ SCREENS . UNLINK_LOGIN ,
51+ SCREENS . SAML_SIGN_IN ,
52+ ] ) ;
53+
3754/**
3855 * Builds TabNavigator state with all tabs and the correct selected tab.
3956 * Tab navigators require all routes in the state for proper rendering.
@@ -355,6 +372,14 @@ function getAdaptedState(state: PartialState<NavigationState<RootNavigatorParamL
355372 return getRoutesWithIndex ( [ getTabNavigatorState ( { name : NAVIGATORS . REPORTS_SPLIT_NAVIGATOR } ) , ...currentState . routes ] ) ;
356373 }
357374
375+ // Public screens (e.g. ValidateLogin) exist in both PublicScreens and AuthScreens navigators.
376+ // Don't prepend TabNavigator because when the user is unauthenticated, PublicScreens is active
377+ // and TabNavigator doesn't exist — causing the RESET action to fail.
378+ const hasOnlyPublicScreens = currentState . routes . every ( ( route ) => PUBLIC_SCREENS . has ( route . name ) ) ;
379+ if ( hasOnlyPublicScreens ) {
380+ return currentState ;
381+ }
382+
358383 const defaultFullScreenRoute = getDefaultFullScreenRoute ( focusedRoute ) ;
359384
360385 // If not, add the default full screen route.
0 commit comments