Skip to content

Commit

Permalink
Simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen committed Jan 17, 2024
1 parent bedb2ae commit dfa7397
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/SettlementButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,14 @@ function SettlementButton({

// Users can choose to pay with business bank account in case of Expense reports or in case of P2P IOU report
// which then starts a bottom up flow and creates a Collect workspace where the payer is an admin and payee is an employee.
const canUseBusinessBankAccount =
if (
ReportUtils.isExpenseReport(iouReport) ||
(ReportUtils.isIOUReport(iouReport) && !ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)));

if (canUseBusinessBankAccount) {
(ReportUtils.isIOUReport(iouReport) && !ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)))
) {
buttonOptions.push(payWithBusinessBankAccountOption);
}

const canUsePersonalBankAccount = shouldShowPersonalBankAccountOption || ReportUtils.isIOUReport(iouReport);
if (canUsePersonalBankAccount) {
if (shouldShowPersonalBankAccountOption || ReportUtils.isIOUReport(iouReport)) {
buttonOptions.push(payWithPersonalBankAccountOption);
}

Expand All @@ -219,7 +217,7 @@ function SettlementButton({
buttonOptions.push(approveButtonOption);
}
return buttonOptions;
}, [iouReport, translate, shouldHidePaymentOptions, shouldShowApproveButton]);
}, [session, iouReport, translate, shouldShowPersonalBankAccountOption, shouldHidePaymentOptions, shouldShowApproveButton]);

const paymentButtonOptions = useMemo(() => {

Check failure on line 222 in src/components/SettlementButton.js

View workflow job for this annotation

GitHub Actions / lint

'paymentButtonOptions' is assigned a value but never used
const buttonOptions = [];
Expand Down

0 comments on commit dfa7397

Please sign in to comment.