Skip to content

Commit

Permalink
Merge pull request #44520 from dominictb/fix/41017-refresh-rhp
Browse files Browse the repository at this point in the history
fix: return to report screen if RHP has valid reportID params
  • Loading branch information
roryabraham authored Jul 9, 2024
2 parents d10c5f6 + f20710d commit 87dba8c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<string, string | undefined>)?.reportID;
if (ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]) {
return {name: SCREENS.REPORT, params: {reportID}};
}
}

function getAdaptedState(state: PartialState<NavigationState<RootStackParamList>>, policyID?: string): GetAdaptedStateReturnType {
Expand Down

0 comments on commit 87dba8c

Please sign in to comment.