diff --git a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts index 2b057bf5edaa..547b766e1ce5 100644 --- a/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts +++ b/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts @@ -6,8 +6,10 @@ import getIsNarrowLayout from '@libs/getIsNarrowLayout'; import type {BottomTabName, CentralPaneName, FullScreenName, NavigationPartialRoute, RootStackParamList} from '@libs/Navigation/types'; import {isCentralPaneName} from '@libs/NavigationUtils'; import {extractPolicyIDFromPath, getPathWithoutPolicyID} from '@libs/PolicyUtils'; +import * as ReportConnection from '@libs/ReportConnection'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; +import ONYXKEYS from '@src/ONYXKEYS'; import SCREENS from '@src/SCREENS'; import CENTRAL_PANE_TO_RHP_MAPPING from './CENTRAL_PANE_TO_RHP_MAPPING'; import config from './config'; @@ -139,6 +141,13 @@ function getMatchingRootRouteForRHPRoute(route: NavigationPartialRoute): Navigat return createFullScreenNavigator({name: fullScreenName as FullScreenName, params: route.params}); } } + + // check for valid reportID in the route params + // if the reportID is valid, we should navigate back to screen report in CPN + const reportID = (route.params as Record)?.reportID; + if (ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) { + return {name: SCREENS.REPORT, params: {reportID}}; + } } function getAdaptedState(state: PartialState>, policyID?: string): GetAdaptedStateReturnType {