Skip to content

Add bank account filter to Search#90791

Open
allgandalf wants to merge 58 commits into
Expensify:mainfrom
allgandalf:add-bank-account-search-filter
Open

Add bank account filter to Search#90791
allgandalf wants to merge 58 commits into
Expensify:mainfrom
allgandalf:add-bank-account-search-filter

Conversation

@allgandalf
Copy link
Copy Markdown
Contributor

@allgandalf allgandalf commented May 15, 2026

Explanation of Change

Adds a new bankAccount filter on the expense Search advanced filters page so users with multiple settlement bank accounts can scope results to a single bank. Picker source is the user's bankAccountList, multi-select, displayed as ${bankName} xx${last4} to match the existing "Bank account" column on withdrawalID grouping. Filter row is gated to expense type and only renders when the user has at least one bank account. Backend half lands in Expensify/Auth#21649.

Fixed Issues

$ #88385
PROPOSAL: #88385 (comment)

Tests

Preconditions (one-time setup):

  • A workspace with ACH reimbursement enabled
  • Two validated withdrawal bank accounts on the workspace, created via ./script/clitools.sh generator:bankaccount (choose Withdrawal, validated, upgraded). Run twice
  • An employee on the policy with a validated deposit bank account so reimbursements can actually settle to them

Seed data:

  1. In workspace settings, set the policy's preferred reimbursement to bank A
  2. Generate reports paid via bank A: ./script/clitools.sh generator:report (answer Y to submit and approve)
  3. Switch the policy's preferred reimbursement to bank B in workspace settings
  4. Generate reports paid via bank B: ./script/clitools.sh generator:report
  5. For each generated report, open the report in NewDot and click Pay via bank account in the report header so the reimbursement actually settles. without this step the filter has no row to match

Filter checks:

  1. Sign in as the admin
  2. Go to Search and confirm the type is Expenses
  3. Tap the Filters button and confirm a new "Bank account" row appears in the advanced filters list
  4. Open the row, confirm each bank account is shown as ${bankName} xx${last4} with the bank icon
  5. Select bank A, save, confirm only the bank-A-paid expenses are returned and the filter chip renders on the search header with the same label
  6. Open the filter again, multi-select bank A and bank B, save, confirm both sets are returned and the chip shows both labels comma-separated
  7. Confirm the URL query has bankAccount:<id> (or <id1>,<id2>) and reloading the page rehydrates the selection
  8. Type bank-account: in the autocomplete bar and confirm the user-friendly suggestions for each bank account appear, alphabetically sorted
  9. Switch the Search type to Chat or Trip and confirm the "Bank account" row no longer shows in advanced filters
  10. Sign in with an account that has no bank accounts and confirm the row does not show even on expense type
  • Verify that no errors appear in the JS console

Offline tests

The filter UI reads from Onyx bankAccountList so the picker, chip rendering, and autocomplete substitution all work offline once the data has been cached. Saving the filter queues a Search request that will be sent on reconnect. Steps:

  1. Go offline before opening the picker, confirm the bank account list still renders
  2. Save a filter selection while offline, confirm the chip renders and the query is queued
  3. Reconnect, confirm the Search request fires with the queued bankAccount filter

QA Steps

Preconditions:

  • A workspace with ACH reimbursement enabled
  • Two validated withdrawal bank accounts on the workspace (admin)
  • An employee on the policy with a validated deposit bank account so reimbursements can settle to them, otherwise the filter has nothing to match
  • At least one expense report submitted, approved, and paid via bank A and another paid via bank B. Use the Pay via bank account button on the report header to actually settle each reimbursement

Steps:

  1. Sign in as the admin
  2. Go to Search and pick the Expenses type
  3. Tap Filters and confirm a "Bank account" row is shown in the advanced filters list
  4. Open the row, confirm each bank account is shown as ${bankName} xx${last4} with the bank icon
  5. Select bank A, save, confirm only the bank-A-paid expenses are returned
  6. Open the filter, multi-select bank A and bank B, save, confirm both sets are returned and the chip shows both labels comma-separated
  7. Type bank-account: in the autocomplete bar and confirm the user-friendly suggestions appear, alphabetically sorted
  8. Switch the Search type to Chat or Trip and confirm the "Bank account" row no longer shows
  9. As an account with no bank accounts visible, confirm the row does not show even on expense type
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
Screen.Recording.2026-05-23.at.3.31.33.PM.mov

allgandalf added 30 commits May 15, 2026 20:55
@dubielzyk-expensify
Copy link
Copy Markdown
Contributor

Looks good from a design perspective 👍

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 25, 2026

@allgandalf lets do a C+ here. @Eskalifer1 would you mind reviewing?

@Eskalifer1
Copy link
Copy Markdown
Contributor

Sure, i will do it

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented May 25, 2026

@allgandalf we just merged #90029, so there'll be some conflicts here

Copy link
Copy Markdown
Contributor

@JS00001 JS00001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

The bank filter renders the bank account id

Comment thread src/libs/SearchParser/baseRules.peggy Outdated
@allgandalf
Copy link
Copy Markdown
Contributor Author

@JS00001 good catch on the chip rendering the raw id. the advanced filters list row was using getFilterDisplayTitle which just stringifies the form value. switched to a new getFilterBankAccountDisplayTitle that maps each id through bankAccountList and getBankAccountSearchLabel. fixed in 8038d1a.

also merged main to clear the conflicts from #90029, see e423cd5. main renamed FILTER_LABEL_MAP to FILTER_VIEW_MAP with {labelKey, icon} shape, added the bank account entry to it with the Bank icon.

@allgandalf allgandalf requested a review from JS00001 May 25, 2026 15:23
Copy link
Copy Markdown
Contributor

@JS00001 JS00001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2026-05-25.at.11.33.18.AM.mov

No longer works on mobile

/ policyName
/ withdrawalId
/ bankAccount
/ bankAccountColumn
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be bankAccountColumn? Should it not be bankAccount?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want the bank account filter to support bank-account and bankAccount?

@Eskalifer1
Copy link
Copy Markdown
Contributor

Hi @allgandalf Is there any way to reproduce these changes using the Alberta dataset? It seems like I've met all the prerequisites, but when I try to search, nothing comes up.

Am I missing something?

2026-05-26.14.00.08.mov

Copy link
Copy Markdown
Contributor

@Eskalifer1 Eskalifer1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In “Recent Searches,” the bank's ID is displayed instead of its name

2026-05-26.14.40.34.mov

Comment on lines +14 to +23
type BankAccountSelectorProps = {
value: string[] | undefined;
onChange: (bankAccounts: string[]) => void;
};

type BankAccountItem = {
text: string;
value: string;
leftElement: React.JSX.Element;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add comments using /** comment above it */ pattern

const selectedBankAccounts = bankAccountItems.filter((item) => value.includes(item.value));

return (
<MultiSelect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get the footer from the props and pass it here as footer={footer}.

Without this, we'll run into a problem where the Confirm button won't appear on the page when viewed on mobile devices.

const selectedBankAccounts = bankAccountItems.filter((item) => value.includes(item.value));

return (
<MultiSelect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get the autoFocus from the props and pass it here as autoFocus={autoFocus}.

Without this, we'll run into a problem where the input field gains focus on a desktop computer, which shouldn't happen.

const selectedBankAccounts = bankAccountItems.filter((item) => value.includes(item.value));

return (
<MultiSelect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get the selectionListTextInputStyle from the props and pass it here as selectionListTextInputStyle={selectionListTextInputStyle}.

Without this, the styles won't display correctly on desktop

const selectedBankAccounts = bankAccountItems.filter((item) => value.includes(item.value));

return (
<MultiSelect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for selectionListStyle

const selectedBankAccounts = bankAccountItems.filter((item) => value.includes(item.value));

return (
<MultiSelect
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add searchPlaceholder here

Comment thread src/CONST/index.ts
TAX_RATE: 'tax-rate',
CARD_ID: 'card',
FEED: 'feed',
BANK_ACCOUNT: 'bankAccount',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use camelCase here?

import ONYXKEYS from '@src/ONYXKEYS';
import MultiSelect from './MultiSelect';

type BankAccountSelectorProps = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add SearchFilterSelectionListProps & here

var peg$e122 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ["a", "z"], ["A", "Z"]], false, false);
var peg$e123 = peg$classExpectation([","], false, false);
var peg$e124 = peg$classExpectation([" ", "\t", "\n", "\r", "\xA0", ","], false, false);
var peg$e29 = peg$literalExpectation("bankAccount", true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we want to support both forms, just like with all the other search filters, so we need to support both bankAccount and bank-account.

I'm leaving a comment here, but this needs to be fixed everywhere, since all the other filters work the same way.

Comment on lines +75 to +82
{!isLoadingOnyxValue(searchAdvancedFiltersFormResult) && (
<SearchMultipleSelectionPicker
items={bankAccountItems}
initiallySelectedItems={initiallySelectedItems}
onSaveSelection={onSaveSelection}
shouldShowTextInput={bankAccountItems.length >= CONST.STANDARD_LIST_ITEM_LIMIT}
/>
)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add a loading indicator here. After all, it might confuse the user if they go to the page and don't see anything at first—just a blank screen.

We can use a similar pattern to the one used in SearchFiltersCardPage

Copy link
Copy Markdown
Contributor

@Eskalifer1 Eskalifer1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be outside the scope of this PR, However, when the user enters an ID, the dropdown menu displays the same bank that the user just entered by ID (bug 1). After the user presses Enter, the value in the search results is updated correctly, but the dropdown menu still shows only one bank—the one that was selected second (bug 2).

2026-05-26.16.00.53.mov

Copy link
Copy Markdown
Contributor

@Eskalifer1 Eskalifer1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we do about the Bank Account column? As far as I understand, we're adding a completely new filter, but the Bank Account column already exists.

@Eskalifer1
Copy link
Copy Markdown
Contributor

@codex review

@Eskalifer1
Copy link
Copy Markdown
Contributor

Let's merge main

cc: @allgandalf

@Eskalifer1
Copy link
Copy Markdown
Contributor

@MelvinBot We're adding a new filter in this PR. Please review the implementation and let us know if there are any issues, edge cases, or improvements we should address.

Also, please look through the history of recently added filters and identify any regressions, missed updates, or recurring issues that happened during previous filter implementations. Then verify whether this PR could introduce any of the same problems, or if there are any related areas we may have overlooked this time.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94e8c346be

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +41 to +42
bankAccount
= "bankAccount"i { return "bankAccount"; }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept kebab-case bank-account filter key

Extend the bankAccount key rule to also accept bank-account (like other multi-word filters) so typed queries and deep links using the standard kebab-case style work. As written, bank-account:42 is parsed as a generic keyword expression instead of a bank-account filter, so users who type the hyphenated form won’t actually apply this new filter.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants