Skip to content

LOW: Implement filtering for search pages. #37619

Closed

Description

@TMisiukiewicz

Problem

Based on our measurements in high-traffic accounts, the search page takes an average of 4100ms to re-render on every keystroke. This is a problem because the user will notice a significant lag between changing their search term and the results list updating.
The root cause of this problem is getSearchText, which is called for every keystroke and is inefficient because it reconstructs all the options in the results list using createOption over and over.

Solution

Let's speed up getSearchText by refactoring it such that, instead of re-generating all the result options every time the search terms change, we just generate the options once and filter them based on the current search term.
To achieve this, we recommend using a rank-value sorting, where a higher number means it will appear higher in the list:

  • Acronym - item’s acronym is the given value
  • Contains - item contains the given value
  • Word starts with - if one of the item’s words starts with the given value
  • Starts with - if the item starts with the given value
  • Equals - case-insensitive equality
  • Case sensitive - case-sensitive equality

Note that this will maintain the current search result ordering, just implement it in a different way. By making this change, we can improve the following metrics:

  • open_search → Before: ~5900ms → After: ~4900ms (~1000ms improvement)
  • load_search_options → Before: ~4100ms → After: ~3200ms (~900ms improvement)
  • search query changed after initial load → Before: 4100ms → After: 350ms (~12x improvement)

We can apply this technique everywhere in the app where we use a search bar to filter option results.

Issue OwnerCurrent Issue Owner: @stephanieelliott

Activity

  1. melvin-bot commented on Mar 1, 2024

    @melvin-bot

    Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext.

  2. melvin-bot commented on Mar 1, 2024

    @melvin-bot
  3. roryabraham commented on Mar 1, 2024

    @roryabraham
    Contributor

    Making @TMisiukiewicz the issue owner here since for now we're just awaiting a PR

  4. TMisiukiewicz commented on Mar 4, 2024

    @TMisiukiewicz
    ContributorAuthor

    Already incorporated the algorithm into the codebase and created an util responsible for filtering, now working on implementing it into the first search page

  5. TMisiukiewicz commented on Mar 7, 2024

    @TMisiukiewicz
    ContributorAuthor

    I just opened a draft PR with an example implementation in Search Page, I would be more than happy to get some initial feedback! @roryabraham how should we approach implementing it in other search pages? Should we implement filtering in all required pages with this single PR or should we get this one merged first and then implement each one separately?
    Once we migrate each search page to use filtering, we will be able to stop using searchText property which will improve the performance of generating options

  6. 101 remaining items

  7. melvin-bot commented on Jul 10, 2024

    @melvin-bot

    BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@TMisiukiewicz] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
    • [@stephanieelliott] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.
  8. changed the title [-][HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [HOLD for payment 2024-07-02] [HOLD for payment 2024-06-11] LOW: Implement filtering for search pages.[/-] [+][HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [HOLD for payment 2024-07-02] [HOLD for payment 2024-06-11] LOW: Implement filtering for search pages.[/+] on Jul 15, 2024
  9. melvin-bot commented on Jul 15, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.6-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2024-07-22. 🎊

    For reference, here are some details about the assignees on this issue:

  10. melvin-bot commented on Jul 15, 2024

    @melvin-bot

    BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@TMisiukiewicz] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
    • [@stephanieelliott] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.
  11. changed the title [-][HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [HOLD for payment 2024-07-10] [HOLD for payment 2024-07-02] [HOLD for payment 2024-06-11] LOW: Implement filtering for search pages.[/-] [+]LOW: Implement filtering for search pages.[/+] on Jul 24, 2024
  12. DylanDylann commented on Oct 16, 2024

    @DylanDylann
    Contributor

    Hi @stephanieelliott According to the payment summary, the payment for me should be $500, but only $250 was paid out (via this offer), can you help re-check on this?

  13. stephanieelliott commented on Oct 24, 2024

    @stephanieelliott
    Contributor

    Oops! So weird, the job was $500 but the milestone was just $250. Sorry about that! Sent another $250 as a bonus on the same job, so we should be square now!

  14. DylanDylann commented on Oct 25, 2024

    @DylanDylann
    Contributor

    @stephanieelliott Thanks so much for looking into this 🥇

  15. Ollyws commented on May 14, 2025

    @Ollyws
    Contributor

    @stephanieelliott I know this issue is absolutely ancient, but I was going through some old PRs and realized that I'd never been paid for my review of #42411
    Could you take a look? Thanks!

  16. mallenexpensify commented on Jul 31, 2025

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Ollyws due $500 via NewDot for PR review

    I checked assignment date and it's after their eligibility date

  17. Ollyws commented on Jul 31, 2025

    @Ollyws
    Contributor

    Requested on ND.

  18. isabelastisser commented on Aug 5, 2025

    @isabelastisser
    Contributor

    @Ollyws has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Vendor found in VML: True. Status: Active

    Amount requested: $500. Matches the payment summary here.

    I am not already the BZ assignee. I have approved this payment.

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 productionEngineeringNewFeatureSomething to build that is a new item.WeeklyKSv2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions