Skip to content

Commit

Permalink
refactor the cancelPayment IOU function
Browse files Browse the repository at this point in the history
  • Loading branch information
cdOut committed Jul 10, 2024
1 parent b1e53c6 commit e98a186
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6604,7 +6604,11 @@ function submitReport(expenseReport: OnyxTypes.Report) {
API.write(WRITE_COMMANDS.SUBMIT_REPORT, parameters, {optimisticData, successData, failureData});
}

function cancelPayment(expenseReport: OnyxTypes.Report, chatReport: OnyxTypes.Report) {
function cancelPayment(expenseReport: OnyxEntry<OnyxTypes.Report>, chatReport: OnyxTypes.Report) {
if (isEmptyObject(expenseReport)) {
return;
}

const optimisticReportAction = ReportUtils.buildOptimisticCancelPaymentReportAction(expenseReport.reportID, -(expenseReport.total ?? 0), expenseReport.currency ?? '');
const policy = PolicyUtils.getPolicy(chatReport.policyID);
const isFree = policy && policy.type === CONST.POLICY.TYPE.FREE;
Expand Down
4 changes: 0 additions & 4 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
return;
}

if (!moneyRequestReport) {
return;
}

IOU.cancelPayment(moneyRequestReport, chatReport);
setIsConfirmModalVisible(false);
}, [moneyRequestReport, chatReport]);
Expand Down

0 comments on commit e98a186

Please sign in to comment.