Skip to content

[Due for payment 2025-10-28] [$250] Web - Category Picker - "Employee Office" Does Not Return "Employee Meals Office" #72615

Closed

Description

@vincdargento

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.2.31-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://github.com/Expensify/Expensify/issues/514326
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team

Action Performed:

Precondition: have "Employee Meals Office" category in WS.

  1. Navigate to the category picker.
  2. Enter "Employee Office" in the search bar.
  3. Observe the search results.

Expected Result:

The category "Employee Meals Office" should appear in the search results when "Employee Office" is searched, as it is a related term.

Actual Result:

The category "Employee Meals Office" does not appear in the search results

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

bug.mp4
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021978203051148613358
  • Upwork Job ID: 1978203051148613358
  • Last Price Increase: 2025-10-14
Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 14, 2025
  2. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. daledah commented on Oct 14, 2025

    @daledah
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The category "Employee Meals Office" does not appear in the search results

    What is the root cause of that problem?

    We are using the includes method to filter here

    const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
    const categoryText = StringUtils.normalize(categoryOption.text?.toLowerCase() ?? '');
    const alternateText = StringUtils.normalize(categoryOption.alternateText?.toLowerCase() ?? '');
    const normalizedSearchInput = StringUtils.normalize(searchInput);
    return categoryText.includes(normalizedSearchInput) || alternateText.includes(normalizedSearchInput);
    }, []);

    What changes do you think we should make in order to solve the problem?

    We should update this function to

        const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
            const categoryText = StringUtils.normalize(categoryOption.text?.toLowerCase() ?? '');
            const alternateText = StringUtils.normalize(categoryOption.alternateText?.toLowerCase() ?? '');
            const normalizedSearchInput = StringUtils.normalize(searchInput.toLowerCase());
    
            // Split search input into tokens (words)
            const searchTokens = normalizedSearchInput.split(CONST.REGEX.WHITESPACE).filter(Boolean);
    
            // If no search tokens, show all items
            if (searchTokens.length === 0) {
                return true;
            }
    
            // Get all text tokens from category text and alternate text
            const categoryTokens: string[] = [];
            for (const text of [categoryText, alternateText]) {
                if (text) {
                    const tokens = text.split(CONST.REGEX.WHITESPACE).filter(Boolean);
                    categoryTokens.push(...tokens);
                }
            }
    
            // Check if all search tokens are found in category tokens
            // Each search token should be a substring of at least one category token
            return searchTokens.every((searchToken) => categoryTokens.some((categoryToken) => categoryToken.includes(searchToken)));
        }, []);
    

    Note: we can create utils function for logic above and we should update other pages that have the same problem as well

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    NA

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 14, 2025
  5. changed the title [-]Web - Category Picker - "Employee Office" Does Not Return "Employee Meals Office"[/-] [+][$250] Web - Category Picker - "Employee Office" Does Not Return "Employee Meals Office"[/+] on Oct 14, 2025
  6. melvin-bot commented on Oct 14, 2025

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 14, 2025
  8. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @dukenv0307 (External)

  9. JmillsExpensify commented on Oct 14, 2025

    @JmillsExpensify
    Contributor

    I would be surprised if this isn't BE though opening for proposals to see where we land.

  10. nyomanjyotisa commented on Oct 14, 2025

    @nyomanjyotisa
    Member

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Web - Category Picker - "Employee Office" Does Not Return "Employee Meals Office"

    What is the root cause of that problem?

    filterCategory function uses a simple substring match with includes to filter categories, which requires the entire search phrase to appear as a continuous substring in the category name

    const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
    const categoryText = StringUtils.normalize(categoryOption.text?.toLowerCase() ?? '');
    const alternateText = StringUtils.normalize(categoryOption.alternateText?.toLowerCase() ?? '');
    const normalizedSearchInput = StringUtils.normalize(searchInput);
    return categoryText.includes(normalizedSearchInput) || alternateText.includes(normalizedSearchInput);
    }, []);

    Other parts of the codebase use tokenizedSearch for search purposes. For example, CategoryOptionListUtils.ts uses tokenizedSearch, which properly handles multi-word searches by checking if each search token appears anywhere in the target text

    const searchCategories: Category[] = tokenizedSearch(categoriesForSearch, searchValue, (category) => [category.name]).map((category) => ({

    What changes do you think we should make in order to solve the problem?

    We should replace the simple substring matching with the existing tokenizedSearch function

        const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
            const results = tokenizedSearch([categoryOption], searchInput, (option) => [option.text ?? '', option.alternateText ?? '']);
            return results.length > 0;
        }, []);

    Or if we want to normalize the search input

        const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
            const normalizedSearchInput = StringUtils.normalize(searchInput);
    
            const results = tokenizedSearch([categoryOption], normalizedSearchInput, (option) => [
                StringUtils.normalize(option.text?.toLowerCase() ?? ''),
                StringUtils.normalize(option.alternateText?.toLowerCase() ?? ''),
            ]);
    
            return results.length > 0;
        }, []);

    const filterCategory = useCallback((categoryOption: PolicyOption, searchInput: string) => {
    const categoryText = StringUtils.normalize(categoryOption.text?.toLowerCase() ?? '');
    const alternateText = StringUtils.normalize(categoryOption.alternateText?.toLowerCase() ?? '');
    const normalizedSearchInput = StringUtils.normalize(searchInput);
    return categoryText.includes(normalizedSearchInput) || alternateText.includes(normalizedSearchInput);
    }, []);

    We should also check and update the other page with the same issue

    What alternative solutions did you explore? (Optional)

    None

  11. github-actions commented on Oct 14, 2025

    @github-actions
    Contributor

    ⚠️ @nyomanjyotisa Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  12. 19 remaining items

  13. melvin-bot commented on Oct 21, 2025

    @melvin-bot

    @dukenv0307 @JmillsExpensify The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  14. dukenv0307 commented on Oct 23, 2025

    @dukenv0307
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/61746/files#r2454418466

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Have "Employee Meals Office" category in WS.
    There are more than 15 entries on the Members, Tags, Taxes, Distance Rates, and Per Diem pages.

    Test:

    1. Navigate to the category picker.
    2. Enter "Employee Office" in the search bar (or first word and last word for another page).
    3. Observe the search results.
    4. Verify that the "Employee Meals Office" category appears in the search results when "Employee Office" is searched.
    5. Repeat the same steps for Members, Tags, Taxes, Distance Rates, and Per Diem (search for entries using the first and last words).

    Do we agree 👍 or 👎

  15. melvin-bot commented on Oct 28, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@JmillsExpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1978203051148613358/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. melvin-bot commented on Oct 31, 2025

    @melvin-bot

    @JmillsExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  17. JmillsExpensify commented on Nov 4, 2025

    @JmillsExpensify
    Contributor

    Payment summary:

  18. JmillsExpensify commented on Nov 4, 2025

    @JmillsExpensify
    Contributor

    Offer sent to contributor. @dukenv0307 please suggest regression test when you get a chance.

  19. dukenv0307 commented on Nov 6, 2025

    @dukenv0307
    Contributor
  20. JmillsExpensify commented on Nov 6, 2025

    @JmillsExpensify
    Contributor

    Nice, Upwork paid out so I'm closing this issue.

  21. garrettmknight commented on Nov 11, 2025

    @garrettmknight
    Contributor

    $250 approved for @dukenv0307

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions