Skip to content

Commit

Permalink
fix: update hold action with correct report ID
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictb committed Jul 30, 2024
1 parent d135c82 commit 01a170a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as ReportUtils from '@libs/ReportUtils';
import * as ReportActions from '@userActions/Report';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type {ReportAction} from '@src/types/onyx';
import type OnyxReport from '@src/types/onyx/Report';
Expand All @@ -28,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; backTo?: string}) => PromotedAction;
hold: (params: {isTextHold: boolean; reportAction: ReportAction | undefined; reportID?: string}) => PromotedAction;
};

const PromotedActions = {
Expand Down Expand Up @@ -69,22 +70,23 @@ const PromotedActions = {
}
},
}),
hold: ({isTextHold, reportAction, backTo}) => ({
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, backTo);
ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.REPORT_WITH_ID.getRoute(targetedReportID));
return;
}

ReportUtils.changeMoneyRequestHoldStatus(reportAction, backTo);
ReportUtils.changeMoneyRequestHoldStatus(reportAction, ROUTES.SEARCH_REPORT.getRoute(targetedReportID));
},
}),
} satisfies PromotedActionsType;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
PromotedActions.hold({
isTextHold: canHoldUnholdReportAction.canHoldRequest,
reportAction: moneyRequestAction,
backTo: ROUTES.REPORT_WITH_ID.getRoute(transactionThreadReportID ? report.reportID : moneyRequestAction?.childReportID ?? '-1'),
reportID: transactionThreadReportID ? report.reportID : moneyRequestAction?.childReportID ?? '-1',
}),
);
}
Expand Down

0 comments on commit 01a170a

Please sign in to comment.