Skip to content
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
13 changes: 2 additions & 11 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {isFullScreenName, isOnboardingFlowName, isSplitNavigatorName} from './he
import isReportOpenInRHP from './helpers/isReportOpenInRHP';
import isReportTopmostSplitNavigator from './helpers/isReportTopmostSplitNavigator';
import isSideModalNavigator from './helpers/isSideModalNavigator';
import isTabNavigatorReady from './helpers/isTabNavigatorReady';
import linkTo from './helpers/linkTo';
import getMinimalAction from './helpers/linkTo/getMinimalAction';
import type {LinkToOptions} from './helpers/linkTo/types';
Expand Down Expand Up @@ -699,16 +698,8 @@ function navContainsProtectedRoutes(state: State | undefined): boolean {
return false;
}

if (!state.routeNames.includes(PROTECTED_SCREENS.CONCIERGE)) {
return false;
}

// routeNames only tells us screens are declared on the root navigator.
// We also need TabNavigator to be mounted (its child router has run
// useNavigationBuilder and produced a non-stale nested state), otherwise a
// deferred NAVIGATE targeting a screen inside TabNavigator will be dispatched
// before any child router is registered to handle it.
return isTabNavigatorReady(state);
// If one protected screen is in the routeNames then other screens are there as well.
return state?.routeNames.includes(PROTECTED_SCREENS.CONCIERGE);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep waiting until TabNavigator mounts

When AuthScreens first mounts, routeNames already contains Concierge even though the nested TabNavigator route may still have no realized child state. Resolving waitForProtectedRoutes() at this point lets callers such as openReportFromDeepLink() dispatch Navigation.navigate(route) for report/workspace routes before the tab child router is registered, which React Navigation cannot handle and the deep link is effectively lost during sign-in/cold-start races. The readiness check needs to include the TabNavigator's mounted/non-stale nested state, not just a protected root screen name.

Useful? React with 👍 / 👎.

}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/libs/Navigation/helpers/isTabNavigatorReady.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/libs/Navigation/linkingConfig/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {LinkingOptions} from '@react-navigation/native';
import {findFocusedRoute} from '@react-navigation/native';
import {Linking} from 'react-native';
import continuePlaidOAuth from '@libs/continuePlaidOAuth';
import isTabNavigatorReady from '@libs/Navigation/helpers/isTabNavigatorReady';
import navigationRef from '@libs/Navigation/navigationRef';
import type {RootNavigatorParamList} from '@libs/Navigation/types';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -32,16 +31,6 @@ const subscribe: LinkingOptions<RootNavigatorParamList>['subscribe'] = (listener
continuePlaidOAuth(url);
return;
}
// Skip forwarding URLs while TabNavigator is mounting — its child
// router hasn't run useNavigationBuilder yet, so React Navigation
// can't handle nested NAVIGATE actions and throws an unhandled-action
// error. Protected-screen deep links will be handled separately by
// openReportFromDeepLink via waitForProtectedRoutes().
const state = navigationRef.current?.getRootState();
if (!isTabNavigatorReady(state)) {
return;
}

listener(url);
});
return () => subscription.remove();
Expand Down
Loading