diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index e7c5466852cf..5f89b2cd4630 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -1,4 +1,4 @@ -import type {NavigationState, PartialState} from '@react-navigation/native'; +import type {NavigationState, PartialState, Route} from '@react-navigation/native'; import {getStateFromPath} from '@react-navigation/native'; import {isAnonymousUser} from '@libs/actions/Session'; import getIsNarrowLayout from '@libs/getIsNarrowLayout'; @@ -151,6 +151,8 @@ function getAdaptedState(state: PartialState const fullScreenNavigator = state.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR); const rhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR); const lhpNavigator = state.routes.find((route) => route.name === NAVIGATORS.LEFT_MODAL_NAVIGATOR); + const reportAttachmentsScreen = state.routes.find((route) => route.name === SCREENS.REPORT_ATTACHMENTS); + if (rhpNavigator) { // Routes // - matching bottom tab @@ -257,6 +259,26 @@ function getAdaptedState(state: PartialState metainfo, }; } + if (reportAttachmentsScreen) { + // Routes + // - matching bottom tab + // - central pane (report screen) of the attachment + // - found report attachments + const routes = []; + const reportAttachments = reportAttachmentsScreen as Route<'ReportAttachments', RootStackParamList['ReportAttachments']>; + + const matchingBottomTabRoute = getMatchingBottomTabRouteForState(state); + routes.push(createBottomTabNavigator(matchingBottomTabRoute, policyID)); + if (!isNarrowLayout) { + routes.push(createCentralPaneNavigator({name: SCREENS.REPORT, params: {reportID: reportAttachments.params?.reportID ?? ''}})); + } + routes.push(reportAttachments); + + return { + adaptedState: getRoutesWithIndex(routes), + metainfo, + }; + } if (bottomTabNavigator) { // Routes // - found bottom tab