Skip to content

Commit

Permalink
Merge pull request #46268 from dominictb/fix/45443-lhn
Browse files Browse the repository at this point in the history
fix: set backTo params when hold
  • Loading branch information
robertjchen authored Jul 30, 2024
2 parents 6bc174f + 01a170a commit 5d26dbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type BasePromotedActions = typeof CONST.PROMOTED_ACTIONS.PIN | typeof CONST.PROM
type PromotedActionsType = Record<BasePromotedActions, (report: OnyxReport) => PromotedAction> & {
message: (params: {reportID?: string; accountID?: number; login?: string}) => PromotedAction;
} & {
hold: (params: {isTextHold: boolean; reportAction: ReportAction | undefined}) => PromotedAction;
hold: (params: {isTextHold: boolean; reportAction: ReportAction | undefined; reportID?: string}) => PromotedAction;
};

const PromotedActions = {
Expand Down Expand Up @@ -70,22 +70,23 @@ const PromotedActions = {
}
},
}),
hold: ({isTextHold, reportAction}) => ({
hold: ({isTextHold, reportAction, reportID}) => ({
key: CONST.PROMOTED_ACTIONS.HOLD,
icon: Expensicons.Stopwatch,
text: Localize.translateLocal(`iou.${isTextHold ? 'hold' : 'unhold'}`),
onSelected: () => {
if (!isTextHold) {
Navigation.goBack();
}
const targetedReportID = reportID ?? reportAction?.childReportID ?? '';
const topmostCentralPaneRoute = getTopmostCentralPaneRoute(navigationRef.getRootState() as State<RootStackParamList>);

if (topmostCentralPaneRoute?.name !== SCREENS.SEARCH.CENTRAL_PANE && isTextHold) {
ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.REPORT_WITH_ID.getRoute(reportAction?.childReportID ?? ''));
ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.REPORT_WITH_ID.getRoute(targetedReportID));
return;
}

ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.SEARCH_REPORT.getRoute(reportAction?.childReportID ?? ''));
ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.SEARCH_REPORT.getRoute(targetedReportID));
},
}),
} satisfies PromotedActionsType;
Expand Down Expand Up @@ -131,4 +132,4 @@ PromotedActionsBar.displayName = 'PromotedActionsBar';
export default PromotedActionsBar;

export {PromotedActions};
export type {PromotedActionsBarProps, PromotedAction};
export type {PromotedAction, PromotedActionsBarProps};
10 changes: 8 additions & 2 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,13 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
}

if (isExpenseReport && shouldShowHoldAction) {
result.push(PromotedActions.hold({isTextHold: canHoldUnholdReportAction.canHoldRequest, reportAction: moneyRequestAction}));
result.push(
PromotedActions.hold({
isTextHold: canHoldUnholdReportAction.canHoldRequest,
reportAction: moneyRequestAction,
reportID: transactionThreadReportID ? report.reportID : moneyRequestAction?.childReportID ?? '-1',
}),
);
}

if (report) {
Expand All @@ -550,7 +556,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
result.push(PromotedActions.share(report));

return result;
}, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest]);
}, [report, moneyRequestAction, canJoin, isExpenseReport, shouldShowHoldAction, canHoldUnholdReportAction.canHoldRequest, transactionThreadReportID]);

const nameSectionExpenseIOU = (
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
Expand Down

0 comments on commit 5d26dbe

Please sign in to comment.