@@ -17,30 +17,24 @@ import useOnyx from '@hooks/useOnyx';
1717import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1818import { useSidebarOrderedReports } from '@hooks/useSidebarOrderedReports' ;
1919import useStyleUtils from '@hooks/useStyleUtils' ;
20- import useSubscriptionPlan from '@hooks/useSubscriptionPlan' ;
2120import useTheme from '@hooks/useTheme' ;
2221import useThemeStyles from '@hooks/useThemeStyles' ;
2322import useWorkspacesTabIndicatorStatus from '@hooks/useWorkspacesTabIndicatorStatus' ;
2423import clearSelectedText from '@libs/clearSelectedText/clearSelectedText' ;
2524import getPlatform from '@libs/getPlatform' ;
2625import interceptAnonymousUser from '@libs/interceptAnonymousUser' ;
27- import { getPreservedNavigatorState } from '@libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState' ;
28- import { getLastVisitedTabPath , getSettingsTabStateFromSessionStorage } from '@libs/Navigation/helpers/lastVisitedTabPathUtils' ;
2926import navigateToWorkspacesPage , { getWorkspaceNavigationRouteState } from '@libs/Navigation/helpers/navigateToWorkspacesPage' ;
30- import { buildCannedSearchQuery , buildSearchQueryJSON , buildSearchQueryString } from '@libs/SearchQueryUtils' ;
3127import type { BrickRoad } from '@libs/WorkspacesSettingsUtils' ;
3228import { getChatTabBrickRoad } from '@libs/WorkspacesSettingsUtils' ;
33- import Navigation from '@navigation/Navigation' ;
3429import navigationRef from '@navigation/navigationRef' ;
35- import type { RootNavigatorParamList , SearchFullscreenNavigatorParamList , State , WorkspaceSplitNavigatorParamList } from '@navigation/types' ;
30+ import type { WorkspaceSplitNavigatorParamList } from '@navigation/types' ;
3631import NavigationTabBarAvatar from '@pages/home/sidebar/NavigationTabBarAvatar' ;
3732import NavigationTabBarFloatingActionButton from '@pages/home/sidebar/NavigationTabBarFloatingActionButton' ;
3833import variables from '@styles/variables' ;
3934import CONST from '@src/CONST' ;
4035import NAVIGATORS from '@src/NAVIGATORS' ;
4136import ONYXKEYS from '@src/ONYXKEYS' ;
42- import ROUTES from '@src/ROUTES' ;
43- import SCREENS from '@src/SCREENS' ;
37+ import type SCREENS from '@src/SCREENS' ;
4438import NAVIGATION_TABS from './NAVIGATION_TABS' ;
4539
4640type NavigationTabBarProps = {
@@ -55,7 +49,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
5549 const { translate, preferredLocale} = useLocalize ( ) ;
5650 const { indicatorColor : workspacesTabIndicatorColor , status : workspacesTabIndicatorStatus } = useWorkspacesTabIndicatorStatus ( ) ;
5751 const { orderedReports} = useSidebarOrderedReports ( ) ;
58- const subscriptionPlan = useSubscriptionPlan ( ) ;
52+
5953 const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT , { canBeMissing : false } ) ;
6054 const navigationState = useNavigationState ( findFocusedRoute ) ;
6155 const initialNavigationRouteState = getWorkspaceNavigationRouteState ( ) ;
@@ -116,7 +110,8 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
116110 }
117111
118112 hideInboxTooltip ( ) ;
119- Navigation . navigate ( ROUTES . HOME ) ;
113+ // We use dispatch here because the correct screens and params are preloaded and set up in usePreloadFullScreenNavigators.
114+ navigationRef . dispatch ( { type : CONST . NAVIGATION . ACTION_TYPE . PUSH , payload : { name : NAVIGATORS . REPORTS_SPLIT_NAVIGATOR } } ) ;
120115 } , [ hideInboxTooltip , selectedTab ] ) ;
121116
122117 const navigateToSearch = useCallback ( ( ) => {
@@ -125,27 +120,8 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
125120 }
126121 clearSelectedText ( ) ;
127122 interceptAnonymousUser ( ( ) => {
128- const rootState = navigationRef . getRootState ( ) as State < RootNavigatorParamList > ;
129- const lastSearchNavigator = rootState . routes . findLast ( ( route ) => route . name === NAVIGATORS . SEARCH_FULLSCREEN_NAVIGATOR ) ;
130- const lastSearchNavigatorState = lastSearchNavigator && lastSearchNavigator . key ? getPreservedNavigatorState ( lastSearchNavigator ?. key ) : undefined ;
131- const lastSearchRoute = lastSearchNavigatorState ?. routes . findLast ( ( route ) => route . name === SCREENS . SEARCH . ROOT ) ;
132-
133- if ( lastSearchRoute ) {
134- const { q, ...rest } = lastSearchRoute . params as SearchFullscreenNavigatorParamList [ typeof SCREENS . SEARCH . ROOT ] ;
135- const queryJSON = buildSearchQueryJSON ( q ) ;
136- if ( queryJSON ) {
137- const query = buildSearchQueryString ( queryJSON ) ;
138- Navigation . navigate (
139- ROUTES . SEARCH_ROOT . getRoute ( {
140- query,
141- ...rest ,
142- } ) ,
143- ) ;
144- return ;
145- }
146- }
147-
148- Navigation . navigate ( ROUTES . SEARCH_ROOT . getRoute ( { query : buildCannedSearchQuery ( ) } ) ) ;
123+ // We use dispatch here because the correct screens and params are preloaded and set up in usePreloadFullScreenNavigators.
124+ navigationRef . dispatch ( { type : CONST . NAVIGATION . ACTION_TYPE . PUSH , payload : { name : NAVIGATORS . SEARCH_FULLSCREEN_NAVIGATOR } } ) ;
149125 } ) ;
150126 } , [ selectedTab ] ) ;
151127
@@ -154,22 +130,10 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
154130 return ;
155131 }
156132 interceptAnonymousUser ( ( ) => {
157- const settingsTabState = getSettingsTabStateFromSessionStorage ( ) ;
158- if ( settingsTabState && ! shouldUseNarrowLayout ) {
159- const stateRoute = findFocusedRoute ( settingsTabState ) ;
160- if ( ! subscriptionPlan && stateRoute ?. name === SCREENS . SETTINGS . SUBSCRIPTION . ROOT ) {
161- Navigation . navigate ( ROUTES . SETTINGS_PROFILE . route ) ;
162- return ;
163- }
164- const lastVisitedSettingsRoute = getLastVisitedTabPath ( settingsTabState ) ;
165- if ( lastVisitedSettingsRoute ) {
166- Navigation . navigate ( lastVisitedSettingsRoute ) ;
167- return ;
168- }
169- }
170- Navigation . navigate ( ROUTES . SETTINGS ) ;
133+ // We use dispatch here because the correct screens and params are preloaded and set up in usePreloadFullScreenNavigators.
134+ navigationRef . dispatch ( { type : CONST . NAVIGATION . ACTION_TYPE . PUSH , payload : { name : NAVIGATORS . SETTINGS_SPLIT_NAVIGATOR } } ) ;
171135 } ) ;
172- } , [ selectedTab , subscriptionPlan , shouldUseNarrowLayout ] ) ;
136+ } , [ selectedTab ] ) ;
173137
174138 /**
175139 * The settings tab is related to SettingsSplitNavigator and WorkspaceSplitNavigator.
0 commit comments