Skip to content

Commit

Permalink
Move the conditional to its on variable in AddPaymentsMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
mountiny committed Nov 27, 2023
1 parent 65c73c1 commit 66cf348
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/AddPaymentMethodMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ const defaultProps = {
function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignment, anchorRef, iouReport, onItemSelected, session}) {
const {translate} = useLocalize();

// 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 = ReportUtils.isExpenseReport(iouReport) ||
(ReportUtils.isIOUReport(iouReport) && !ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)));

return (
<PopoverMenu
isVisible={isVisible}
Expand All @@ -84,11 +89,7 @@ function AddPaymentMethodMenu({isVisible, onClose, anchorPosition, anchorAlignme
},
]
: []),

// 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.
...(ReportUtils.isExpenseReport(iouReport) ||
(ReportUtils.isIOUReport(iouReport) && !ReportActionsUtils.hasRequestFromCurrentAccount(lodashGet(iouReport, 'reportID', 0), lodashGet(session, 'accountID', 0)))
...(canUseBusinessBankAccount
? [
{
text: translate('common.businessBankAccount'),
Expand Down

0 comments on commit 66cf348

Please sign in to comment.