Skip to content

Commit

Permalink
Merge pull request #4262 from Expensify/stites-fixBrokenSlice
Browse files Browse the repository at this point in the history
Prevent accounts without account numbers from breaking the payments page
  • Loading branch information
Clement DAL PALU authored Jul 28, 2021
2 parents de5b024 + ae9cc84 commit aab1fbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function getPaymentMethods() {
return API.Get({
returnValueList: 'bankAccountList, cardList, userWallet, nameValuePairs',
name: 'paypalMeAddress',
includeDeleted: false,
includeNotIssued: false,
})
.then((response) => {
Onyx.multiSet({
Expand Down
12 changes: 10 additions & 2 deletions src/pages/settings/Payments/PaymentMethodList.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,17 @@ class PaymentMethodList extends Component {
_.each(this.props.bankAccountList, (bankAccount) => {
// Add all bank accounts besides the wallet
if (bankAccount.type !== CONST.BANK_ACCOUNT_TYPES.WALLET) {
const formattedBankAccountNumber = bankAccount.accountNumber
? `${this.props.translate('paymentMethodList.accountLastFour')} ${
bankAccount.accountNumber.slice(-4)
}`
: null;
combinedPaymentMethods.push({
type: MENU_ITEM,
title: bankAccount.addressName,

// eslint-disable-next-line
description: `${this.props.translate('paymentMethodList.accountLastFour')} ${bankAccount.accountNumber.slice(-4)}`,
description: formattedBankAccountNumber,
icon: Bank,
onPress: e => this.props.onPress(e, bankAccount.bankAccountID),
key: `bankAccount-${bankAccount.bankAccountID}`,
Expand All @@ -99,12 +104,15 @@ class PaymentMethodList extends Component {
_.each(this.props.cardList, (card) => {
// Add all cards besides the "cash" card
if (card.cardName !== CONST.CARD_TYPES.DEFAULT_CASH) {
const formattedCardNumber = card.cardNumber
? `${this.props.translate('paymentMethodList.cardLastFour')} ${card.cardNumber.slice(-4)}`
: null;
combinedPaymentMethods.push({
type: MENU_ITEM,
title: card.cardName,

// eslint-disable-next-line
description: `${this.props.translate('paymentMethodList.cardLastFour')} ${card.cardNumber.slice(-4)}`,
description: formattedCardNumber,
icon: CreditCard,
onPress: e => this.props.onPress(e, card.cardID),
key: `card-${card.cardID}`,
Expand Down

0 comments on commit aab1fbc

Please sign in to comment.