Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function AvatarWithDisplayName({
}, [parentReportActions, report]);

const goToDetailsPage = useCallback(() => {
navigateToDetailsPage(report, Navigation.getReportRHPActiveRoute());
navigateToDetailsPage(report, Navigation.getActiveRoute());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a concern about whether it will cause any regression.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We missed adding the backTo param when opening the RHP for these two places

Your RCA is not really correct, we already have backTo param with Navigation.getReportRHPActiveRoute currently

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoangzinh Thanks for the review.

The getReportRHPActiveRoute function currently passes backTo only for the SearchReport screen. However, since we open the RHP from multiple places within the Report screen, we would need to pass backTo from there as well. That said, we don’t require backTo for those cases. Therefore, I decided not to check for Report as well in the following function. We only need to handle backTo for those two specific cases.

const isReportOpenInRHP = (state: NavigationState | undefined): boolean => {
const lastRoute = state?.routes?.at(-1);
if (!lastRoute) {
return false;
}
const params = lastRoute.params;
if (params && 'screen' in params && typeof params.screen === 'string' && params.screen === SCREENS.RIGHT_MODAL.SEARCH_REPORT) {
return true;
}
return !!(lastRoute.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && lastRoute.state?.routes?.some((route) => route?.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT));
};

The getReportRHPActiveRoute function is used in multiple places, so any changes to it may introduce regressions.

/**
* Returns the route of a report opened in RHP.
*/
function getReportRHPActiveRoute(): string {
if (isReportOpenInRHP(navigationRef.getRootState())) {
return getActiveRoute();
}
return '';
}

So I simply replaced it with getActiveRoute in the two places where it's needed.

}, [report]);

const showActorDetails = useCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
text: translate('iou.viewDetails'),
icon: Expensicons.Info,
onSelected: () => {
navigateToDetailsPage(report, Navigation.getReportRHPActiveRoute());
navigateToDetailsPage(report, Navigation.getActiveRoute());
},
},
[CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.DELETE]: {
Expand Down