Skip to content

Commit ad84a77

Browse files
committed
suggest closed business accounts in autocomplete to match the picker
1 parent ceaa434 commit ad84a77

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/hooks/useAutocompleteSuggestions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {LocaleContextProps} from '@components/LocaleContextProvider';
55
import type {SubstitutionMap} from '@components/Search/SearchRouter/getQueryWithSubstitutions';
66
import {getSubstitutionMapKey, getSubstitutionMapKeyWithIndex} from '@components/Search/SearchRouter/getQueryWithSubstitutions';
77
import type {SearchFilterKey, UserFriendlyKey} from '@components/Search/types';
8-
import {getBankAccountSearchLabel, getSearchEligibleBankAccounts} from '@libs/BankAccountUtils';
8+
import {getBankAccountSearchLabel, isBankAccountPartiallySetup} from '@libs/BankAccountUtils';
99
import {getCardFeedsForDisplay} from '@libs/CardFeedUtils';
1010
import {getCardDescription, isCard, isCardHiddenFromSearch} from '@libs/CardUtils';
1111
import {getDecodedCategoryName} from '@libs/CategoryUtils';
@@ -426,13 +426,18 @@ function useAutocompleteSuggestions({
426426
}));
427427
}
428428
case CONST.SEARCH.SYNTAX_FILTER_KEYS.BANK_ACCOUNT: {
429-
const bankAccounts = Object.values(getSearchEligibleBankAccounts(bankAccountList));
430429
const bankAccountSuggestions: Array<{id: string; label: string; accountNumber: string}> = [];
431-
for (const bankAccount of bankAccounts) {
430+
for (const bankAccount of Object.values(bankAccountList ?? {})) {
432431
const bankAccountID = bankAccount?.accountData?.bankAccountID;
433432
if (!bankAccountID) {
434433
continue;
435434
}
435+
if (bankAccount?.accountData?.type !== CONST.BANK_ACCOUNT.TYPE.BUSINESS) {
436+
continue;
437+
}
438+
if (isBankAccountPartiallySetup(bankAccount?.accountData?.state)) {
439+
continue;
440+
}
436441
const accountNumber = bankAccount?.accountData?.accountNumber ?? '';
437442
const label = getBankAccountSearchLabel(bankAccount);
438443
bankAccountSuggestions.push({id: bankAccountID.toString(), label, accountNumber});

0 commit comments

Comments
 (0)