Repository navigation
Description
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 Owner
Current Issue Owner: @stephanieelliottMetadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
melvin-bot commentedon Mar 1, 2024
Auto-assigning issues to engineers is no longer supported. If you think this issue should receive engineering attention, please raise it in #whatsnext.
melvin-bot commentedon Mar 1, 2024
Triggered auto assignment to @stephanieelliott (
NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details.roryabraham commentedon Mar 1, 2024
Making @TMisiukiewicz the issue owner here since for now we're just awaiting a PR
TMisiukiewicz commentedon Mar 4, 2024
Already incorporated the algorithm into the codebase and created an util responsible for filtering, now working on implementing it into the first search page
TMisiukiewicz commentedon Mar 7, 2024
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
searchTextproperty which will improve the performance of generating options101 remaining items
melvin-bot commentedon Jul 10, 2024
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:
[-][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.[/+]melvin-bot commentedon Jul 15, 2024
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:
melvin-bot commentedon Jul 15, 2024
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:
[-][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.[/+]DylanDylann commentedon Oct 16, 2024
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?
stephanieelliott commentedon Oct 24, 2024
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!
DylanDylann commentedon Oct 25, 2024
@stephanieelliott Thanks so much for looking into this 🥇
Ollyws commentedon May 14, 2025
@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!
mallenexpensify commentedon Jul 31, 2025
Payment Summary
Contributor+: @Ollyws due $500 via NewDot for PR review
I checked assignment date and it's after their eligibility date
Ollyws commentedon Jul 31, 2025
Requested on ND.
isabelastisser commentedon Aug 5, 2025
@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.