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' ;
@@ -158,17 +157,8 @@ export default function linkTo(navigation: NavigationContainerRef<RootNavigatorP
158157 return ;
159158 }
160159
161- const isDynamicRoute = ! ! findMatchingDynamicSuffix ( normalizedPath ) ;
162160 const typedPayload = ( action as { payload : { name ?: string ; params ?: ActionPayloadParams } } ) . payload ;
163161
164- // If a RIGHT_MODAL_NAVIGATOR already sits below the focused TAB_NAVIGATOR, NAVIGATE pops back to it
165- // (dropping the tab above) instead of stacking - anchoring the new RHP on the wrong tab.
166- // PUSH so the new RHP lands above the current tab. See https://github.com/Expensify/App/issues/88965.
167- const targetIsRightModal = typedPayload ?. name === NAVIGATORS . RIGHT_MODAL_NAVIGATOR ;
168- const focusIsOnTabNavigator = currentState . routes [ currentState . index ] ?. name === NAVIGATORS . TAB_NAVIGATOR ;
169- const isRhpNavigationFromStackedTab =
170- targetIsRightModal && focusIsOnTabNavigator && currentState . routes . some ( ( route , index ) => route . name === NAVIGATORS . RIGHT_MODAL_NAVIGATOR && index < currentState . index ) ;
171-
172162 if ( forceReplace ) {
173163 action . type = CONST . NAVIGATION . ACTION_TYPE . REPLACE ;
174164 }
@@ -181,8 +171,7 @@ export default function linkTo(navigation: NavigationContainerRef<RootNavigatorP
181171 action . type === CONST . NAVIGATION . ACTION_TYPE . NAVIGATE &&
182172 ! isNavigatingToAttachmentScreen ( focusedRouteFromPath ?. name ) &&
183173 ! isNavigatingToReportWithSameReportID ( currentFocusedRoute , focusedRouteFromPath ) &&
184- ! isSwitchingTabsWithinTabNavigator ( currentState , stateFromPath ) &&
185- ( ! isDynamicRoute || isRhpNavigationFromStackedTab )
174+ ! isSwitchingTabsWithinTabNavigator ( currentState , stateFromPath )
186175 ) {
187176 // We want to PUSH by default to add entries to the browser history.
188177 action . type = CONST . NAVIGATION . ACTION_TYPE . PUSH ;
0 commit comments