Skip to content

Commit

Permalink
Merge pull request #52971 from Shahidullah-Muffakir/fix/52641
Browse files Browse the repository at this point in the history
Display 'Make default payment method' option for the first bank account without requiring a refresh after adding the second account
  • Loading branch information
techievivek authored Nov 26, 2024
2 parents 04ac4c6 + c7c9f5e commit df4f8b8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/settings/Wallet/WalletPage/WalletPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,22 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) {
}
}
}, [hideDefaultDeleteMenu, paymentMethod.methodID, paymentMethod.selectedPaymentMethodType, bankAccountList, fundList, shouldShowDefaultDeleteMenu]);
// Don't show "Make default payment method" button if it's the only payment method or if it's already the default
const isCurrentPaymentMethodDefault = () => {
const hasMultiplePaymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, fundList ?? {}, styles).length > 1;
if (hasMultiplePaymentMethods) {
if (paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) {
return paymentMethod.selectedPaymentMethod.bankAccountID === userWallet?.walletLinkedAccountID;
}
if (paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.DEBIT_CARD) {
return paymentMethod.selectedPaymentMethod.fundID === userWallet?.walletLinkedAccountID;
}
}
return true;
};

const shouldShowMakeDefaultButton =
!paymentMethod.isSelectedPaymentMethodDefault &&
!isCurrentPaymentMethodDefault() &&
!(paymentMethod.formattedSelectedPaymentMethod.type === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT && paymentMethod.selectedPaymentMethod.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS);

// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
Expand Down

0 comments on commit df4f8b8

Please sign in to comment.