diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index f51f7fae3fb7..d7bcfbb68952 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -183,18 +183,19 @@ function getAdaptedState(state: PartialState if (!matchingRootRoute || isRHPScreenOpenedFromLHN) { metainfo.isCentralPaneAndBottomTabMandatory = false; metainfo.isFullScreenNavigatorMandatory = false; - matchingRootRoute = matchingRootRoute ?? createCentralPaneNavigator({name: SCREENS.REPORT}); + // If matchingRootRoute is undefined and it's a narrow layout, don't add a report screen under the RHP. + matchingRootRoute = matchingRootRoute ?? (!isNarrowLayout ? createCentralPaneNavigator({name: SCREENS.REPORT}) : undefined); } // If the root route is type of FullScreenNavigator, the default bottom tab will be added. - const matchingBottomTabRoute = getMatchingBottomTabRouteForState({routes: [matchingRootRoute]}); + const matchingBottomTabRoute = getMatchingBottomTabRouteForState({routes: matchingRootRoute ? [matchingRootRoute] : []}); routes.push(createBottomTabNavigator(matchingBottomTabRoute, policyID)); // When we open a screen in RHP from FullScreenNavigator, we need to add the appropriate screen in CentralPane. // Then, when we close FullScreenNavigator, we will be redirected to the correct page in CentralPane. - if (matchingRootRoute.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { + if (matchingRootRoute?.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { routes.push(createCentralPaneNavigator({name: SCREENS.SETTINGS.WORKSPACES})); } - if (!isNarrowLayout || !isRHPScreenOpenedFromLHN) { + if (matchingRootRoute && (!isNarrowLayout || !isRHPScreenOpenedFromLHN)) { routes.push(matchingRootRoute); } }