Skip to content

Commit

Permalink
Merge pull request #22846 from Expensify/vit-makeTheSettlementButtonS…
Browse files Browse the repository at this point in the history
…ticky

Make sure the IOU or expense level settlement button defaults to last used method
  • Loading branch information
neil-marcellini authored Jul 18, 2023
2 parents 21d14c5 + 3a94903 commit 0432a30
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/SettlementButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class SettlementButton extends React.Component {

// To achieve the one tap pay experience we need to choose the correct payment type as default,
// if user already paid for some request or expense, let's use the last payment method or use default.
let paymentMethod = this.props.nvp_lastPaymentMethod[this.props.policyID] || '';
if (!this.props.shouldShowPaymentOptions) {
let paymentMethod = this.props.nvp_lastPaymentMethod[this.props.policyID];
if (!paymentMethod) {
// In case the user hasn't paid a request yet, let's default to VBBA payment type in case of expense reports
if (isExpenseReport) {
Expand Down Expand Up @@ -145,6 +145,11 @@ class SettlementButton extends React.Component {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.PAYPAL_ME]);
}
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]);

// Put the preferred payment method to the front of the array so its shown as default
if (paymentMethod) {
return _.sortBy(buttonOptions, (method) => (method.value === paymentMethod ? 0 : 1));
}
return buttonOptions;
}

Expand Down

0 comments on commit 0432a30

Please sign in to comment.