11import { getActionFromState } from '@react-navigation/core' ;
22import type { NavigationContainerRef , NavigationState , PartialState } from '@react-navigation/native' ;
33import { CommonActions , findFocusedRoute } from '@react-navigation/native' ;
4- import findMatchingDynamicSuffix from '@libs/Navigation/helpers/dynamicRoutesUtils/findMatchingDynamicSuffix' ;
54import { getMatchingFullScreenRoute , isFullScreenName } from '@libs/Navigation/helpers/getAdaptedStateFromPath' ;
65import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath' ;
76import normalizePath from '@libs/Navigation/helpers/normalizePath' ;
@@ -169,17 +168,8 @@ export default function linkTo(navigation: NavigationContainerRef<RootNavigatorP
169168 return ;
170169 }
171170
172- const isDynamicRoute = ! ! findMatchingDynamicSuffix ( normalizedPath ) ;
173171 const typedPayload = ( action as { payload : { name ?: string ; params ?: ActionPayloadParams } } ) . payload ;
174172
175- // If a RIGHT_MODAL_NAVIGATOR already sits below the focused TAB_NAVIGATOR, NAVIGATE pops back to it
176- // (dropping the tab above) instead of stacking - anchoring the new RHP on the wrong tab.
177- // PUSH so the new RHP lands above the current tab. See https://github.com/Expensify/App/issues/88965.
178- const targetIsRightModal = typedPayload ?. name === NAVIGATORS . RIGHT_MODAL_NAVIGATOR ;
179- const focusIsOnTabNavigator = currentState . routes [ currentState . index ] ?. name === NAVIGATORS . TAB_NAVIGATOR ;
180- const isRhpNavigationFromStackedTab =
181- targetIsRightModal && focusIsOnTabNavigator && currentState . routes . some ( ( route , index ) => route . name === NAVIGATORS . RIGHT_MODAL_NAVIGATOR && index < currentState . index ) ;
182-
183173 if ( forceReplace ) {
184174 action . type = CONST . NAVIGATION . ACTION_TYPE . REPLACE ;
185175 }
@@ -192,8 +182,7 @@ export default function linkTo(navigation: NavigationContainerRef<RootNavigatorP
192182 action . type === CONST . NAVIGATION . ACTION_TYPE . NAVIGATE &&
193183 ! isNavigatingToAttachmentScreen ( focusedRouteFromPath ?. name ) &&
194184 ! isNavigatingToReportWithSameReportID ( currentFocusedRoute , focusedRouteFromPath ) &&
195- ! isSwitchingTabsWithinTabNavigator ( currentState , stateFromPath ) &&
196- ( ! isDynamicRoute || isRhpNavigationFromStackedTab )
185+ ! isSwitchingTabsWithinTabNavigator ( currentState , stateFromPath )
197186 ) {
198187 // We want to PUSH by default to add entries to the browser history.
199188 action . type = CONST . NAVIGATION . ACTION_TYPE . PUSH ;
0 commit comments