Skip to content

Add text-based filter length validation#94013

Merged
JS00001 merged 17 commits into
Expensify:mainfrom
bernhardoj:fix/84877-add-text-filter-validation-back
Jul 7, 2026
Merged

Add text-based filter length validation#94013
JS00001 merged 17 commits into
Expensify:mainfrom
bernhardoj:fix/84877-add-text-filter-validation-back

Conversation

@bernhardoj

@bernhardoj bernhardoj commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixed Issues

$ #84877
PROPOSAL:

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

Same as QA Steps

QA Steps

  1. Go to Spend

  2. Enter a very long value into the text-based filter that exceeds its max. length
    Max length:
    Description: 1000
    Merchant: 255
    Title: 10000
    Others: 15000
    NOTE: Android natively has a max length of 5000

  3. Verify an error is shown

  4. Verify pressing the apply/confirm button does nothing

  • 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 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)
  • 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)
  • 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.
  • 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.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@bernhardoj bernhardoj requested review from a team as code owners June 19, 2026 07:32
@melvin-bot melvin-bot Bot requested review from aimane-chnaif and heyjennahay and removed request for a team and heyjennahay June 19, 2026 07:32
@melvin-bot

melvin-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team June 19, 2026 07:32
Comment thread src/components/Search/hooks/useTextFilterValidation.tsx Outdated

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

Copy link
Copy Markdown

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: 0c482d10fc

ℹ️ 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 thread src/components/Search/hooks/useTextFilterValidation.tsx
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/Search/FilterComponents/index.tsx 0.00% <ø> (ø)
...omponents/Search/hooks/useTextFilterValidation.tsx 100.00% <100.00%> (ø)
src/libs/SearchUIUtils.ts 62.63% <100.00%> (+0.02%) ⬆️
src/types/form/SearchAdvancedFiltersForm.ts 100.00% <100.00%> (ø)
...s/AdvancedFilters/SearchAdvancedFiltersContent.tsx 0.00% <0.00%> (ø)
...onents/Search/FilterDropdowns/ReportFieldPopup.tsx 0.00% <0.00%> (ø)
...nents/AdvancedFilters/ReportFieldFilterContent.tsx 0.00% <0.00%> (ø)
...h/FilterComponents/ReportField/ReportFieldText.tsx 0.00% <0.00%> (ø)
...ts/Search/SearchPageHeader/useSearchFiltersBar.tsx 17.74% <0.00%> (-1.23%) ⬇️
...ents/Search/FilterComponents/ReportField/index.tsx 0.00% <0.00%> (ø)
... and 2 more
... and 13 files with indirect coverage changes

@bernhardoj

Copy link
Copy Markdown
Contributor Author

@aimane-chnaif bump for review

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Sorry forgot this PR. Please pull main

@bernhardoj

Copy link
Copy Markdown
Contributor Author

@aimane-chnaif done

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Should we set max width to the pill? Happening on production so not blocker.

Screenshot 2026-07-03 at 5 57 06 PM

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Please address bot review comments.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

Done

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Confirmed:

Merchant: 255
Description: 1000
Report ID: 15000
Report field: 15000
Keyword: 15000
Title: 10000

@aimane-chnaif

Copy link
Copy Markdown
Contributor

I noticed different behavior in android native.

On android, there's character limit natively. Max 5000 characters so we can't see error for Report ID, Report field, Keyword, Title.
Not blocker but test steps needs updated to reflect this.

android.mov

@melvin-bot melvin-bot Bot requested review from JS00001 and luacmartins July 4, 2026 17:34
@bernhardoj

Copy link
Copy Markdown
Contributor Author

Added a note

JS00001
JS00001 previously approved these changes Jul 6, 2026
@JS00001

JS00001 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@luacmartins ready for you!

@luacmartins luacmartins left a comment

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.

Looks good. Just one minor comment. We also have conflicts now

onChange: (value: string | undefined) => void;
};

function isTextInput(el: BaseTextInputRef | RNTextInput | null): el is RNTextInput {

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 the other instances below

Suggested change
function isTextInput(el: BaseTextInputRef | RNTextInput | null): el is RNTextInput {
function isTextInput(element: BaseTextInputRef | RNTextInput | null): element is RNTextInput {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@JS00001

JS00001 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@luacmartins reviewed before & all comments are addressed, so going to go ahead and merge this since its blocking #95023

@JS00001 JS00001 merged commit 221df64 into Expensify:main Jul 7, 2026
35 checks passed
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

OSBotify commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.4.29-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against the help site files under docs/articles.

No help site changes are required.

This PR adds a max-length validation guardrail to the text-based Search filters (Merchant, Description, Title, Report ID, Keyword, Withdrawal ID) on the Spend page — when the entered value exceeds the field's character limit, an inline error is shown and the Apply/Confirm button is blocked.

The only article that documents these filters, Getting Started with the Spend Page, explains how to apply filters but does not document per-field character limits, and it shouldn't need to — these limits are an internal input-validation guardrail rather than a user-facing feature. Documenting arbitrary character counts (e.g. 1000 for Description, 255 for Merchant) would add noise without helping users, and the values could drift from the code over time.

No draft PR was created since there is nothing to change.

@bernhardoj, please confirm you agree no help site update is needed here. If you'd like the character limits documented anyway, let me know and I'll open a draft PR.

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.4.31-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against Expensify's help site files under App/docs/articles.

No help site changes are required.

This PR adds max-length input validation to the text-based Search filters (Merchant, Description, Report ID, keyword, Title, Withdrawal ID) and report-field text filters — showing an inline error and blocking apply/confirm when a value exceeds its character limit. This is an internal UI guardrail, not a documented, user-facing feature.

I checked the Search-related help articles and none of them document character/length limits for filter inputs:

  • new-expensify/reports-and-expenses/Search-and-Download-Expenses.md
  • new-expensify/reports-and-expenses/Use-Search-Operators-to-Filter-and-Analyze.md
  • new-expensify/reports-and-expenses/Use-Search-Shortcuts.md
  • new-expensify/reports-and-expenses/Accounting-Search-Shortcuts.md

The change doesn't alter any documented workflow, tab name, settings label, or button, so there's nothing to update on the help site and no draft PR is needed.

@bernhardoj, if you believe this behavior (e.g. the specific max-length limits) should be documented for users, let me know and I'll draft a help site PR.

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.31-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

6 participants