Skip to content

Commit

Permalink
Merge pull request #29915 from Expensify/joel_checkPaymentMethods
Browse files Browse the repository at this point in the history
Do not check for defaultCredit

(cherry picked from commit fda38e2)
  • Loading branch information
chiragsalian authored and OSBotify committed Oct 20, 2023
1 parent ce151e7 commit f20b8d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/libs/PaymentUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import PaymentMethod from '../types/onyx/PaymentMethod';
type AccountType = BankAccount['accountType'] | Fund['accountType'];

/**
* Check to see if user has either a debit card or personal bank account added
* Check to see if user has either a debit card or personal bank account added that can be used with a wallet.
*/
function hasExpensifyPaymentMethod(fundList: Record<string, Fund>, bankAccountList: Record<string, BankAccount>, shouldIncludeDebitCard = true): boolean {
const validBankAccount = Object.values(bankAccountList).some((bankAccountJSON) => {
const bankAccount = new BankAccountModel(bankAccountJSON);
return bankAccount.getPendingAction() !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && bankAccount.isDefaultCredit();

return bankAccount.getPendingAction() !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && bankAccount.isOpen() && bankAccount.getType() === CONST.BANK_ACCOUNT.TYPE.PERSONAL;
});

// Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them
Expand Down
8 changes: 6 additions & 2 deletions src/libs/models/BankAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ class BankAccount {
return this.json.accountData.allowDebit === true;
}

getType() {
return this.json.accountData.type;
}

/**
* Return the client ID of this bank account
*
Expand All @@ -147,14 +151,14 @@ class BankAccount {
*/
getClientID() {
// eslint-disable-next-line max-len
return `${Str.makeID(this.getMaskedAccountNumber())}${Str.makeID(this.getAddressName())}${Str.makeID(this.getRoutingNumber())}${this.getType()}`;
return `${Str.makeID(this.getMaskedAccountNumber())}${Str.makeID(this.getAddressName())}${Str.makeID(this.getRoutingNumber())}${this.getTransactionType()}`;
}

/**
* @returns {String}
* @private
*/
getType() {
getTransactionType() {
return this.isWithdrawal() ? 'withdrawal' : 'direct-deposit';
}

Expand Down

0 comments on commit f20b8d2

Please sign in to comment.