Skip to content

[$250] Investigate SearchAutocompleteList causing 2x slowdown during message sending #91846

Closed

Description

@cristipaval

Problem

When a user navigates to a chat via Search (instead of Inbox), SearchAutocompleteList renders in the background and reacts to message sending. Together with useFilteredOptions, it takes most of the render time and makes ManualSendMessage ~2x slower.

See investigation: #77176 (comment)

Goal

Investigate and fix the unnecessary background re-rendering of SearchAutocompleteList during message send. Possible approaches:

  • Defer/pause rendering of SearchAutocompleteList when it's not visible
  • Stabilize the inputs to useFilteredOptions so it doesn't recompute on unrelated Onyx changes
  • Lazy-mount the autocomplete list only when the search input is focused

Parent issue

$ #77176

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit

Activity

  1. melvin-bot commented on Jun 1, 2026

    @melvin-bot

    @LukasMod Huh... This is 4 days overdue. Who can take care of this?

  2. VickyStash commented on Jun 2, 2026

    @VickyStash
    Contributor

    Not overdue!
    @LukasMod is OOO this week, someone from callstack will take it over as soon as they have capacity.

  3. rinej commented on Jun 2, 2026

    @rinej
    Contributor

    I'm wrapping up some other tasks, I can help with that

  4. cristipaval commented on Jun 2, 2026

    @cristipaval
    ContributorAuthor

    We agreed here that this can wait until @LukasMod is back. You can still take over, @rinej, just saying in case you have higher priority issues on your plate.

  5. cristipaval commented on Jun 5, 2026

    @cristipaval
    ContributorAuthor

    Not overdue, we'll continue on this one on Monday

  6. rinej commented on Jun 8, 2026

    @rinej
    Contributor

    I've got some ideas how to prevent the double rendering. Going to benchmark and test it.
    Draft PR - #92938

  7. 26 remaining items

  8. wanrenjiro06 commented on Jun 15, 2026

    @wanrenjiro06

    Proposal

    Problem:
    When navigating to a chat via Search, SearchAutocompleteList stays mounted in background and re-renders on every message send because useFilteredOptions subscribes to COLLECTION.REPORT — which updates on every send. This causes ~2x slowdown in ManualSendMessage.

    Root Cause:
    useFilteredOptions subscribes to COLLECTION.REPORT, PERSONAL_DETAILS_LIST, COLLECTION.POLICY. Message send triggers COLLECTION.REPORT update → full options list recomputes in background.

    Solution — Lazy mount (Option 3):
    Only mount SearchAutocompleteList when search input is focused:

    const [isSearchFocused, setIsSearchFocused] = useState(false);

    {isSearchFocused && (
    <SearchAutocompleteList
    autocompleteQueryValue={queryValue}
    // ...other props
    />
    )}

    <TextInput
    onFocus={() => setIsSearchFocused(true)}
    onBlur={() => setIsSearchFocused(false)}
    />

    Why lazy mount over other options:

    • Option 1 (defer) — still subscribed to Onyx, doesn't fix root cause
    • Option 2 (stabilize inputs) — hard to prevent COLLECTION.REPORT triggers safely
    • Option 3 (lazy mount) — zero background subscription cost, clean solution

    Files to modify:

    • Parent component rendering SearchAutocompleteList (Search router)
    • Add isSearchFocused state + conditional mount
    • Pass onFocus/onBlur to TextInput

    Testing:

    1. Navigate to chat via Search → send message → measure render time (should match Inbox navigation)
    2. Tap search bar → SearchAutocompleteList mounts, works normally
    3. Blur search → unmounts
    4. Send message → no slowdown

    Expensify Email: wanrenjiro06@gmail.com
    Upwork Profile: https://www.upwork.com/freelancers/~0105d5114cf3ae419f?mp_source=share

  9. rinej commented on Jun 16, 2026

    @rinej
    Contributor

    @cristipaval do we need those proposals?

  10. cristipaval commented on Jun 17, 2026

    @cristipaval
    ContributorAuthor

    @rinej, no, ignore them. I added the External label to have a C+ auto-assigned.

  11. melvin-bot commented on Jun 23, 2026

    @melvin-bot

    @rinej Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. melvin-bot commented on Jun 25, 2026

    @melvin-bot

    @rinej Eep! 4 days overdue now. Issues have feelings too...

  13. nyomanjyotisa commented on Jun 26, 2026

    @nyomanjyotisa
    Member

    BugZero Checklist:

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

      Link to the comment on the PR: N/A. This is a performance improvement
      Link to the comment on the Issue: N/A

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

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

      Link to issue: https://github.com/Expensify/Expensify/issues/653184

    Regression Test Proposal

    Precondition:

    Test:

    1. Open the app on a mobile device (iOS or Android)
    2. Open Search
    3. Select one of the recent chats
    4. Type and send a new message in the chat
    5. Go back using:
      a) the top navigation back button
      b) the swipe-back gesture or device back button
    6. Verify the recent chat shows the new message as its latest message preview
    7. Try it 2-3 times

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-6693-aaea-3462-63da1ce7d3c4
  14. nyomanjyotisa commented on Jun 26, 2026

    @nyomanjyotisa
    Member

    The automation failed here. This should've been due for payment on June 26 @cristipaval

  15. rinej commented on Jun 26, 2026

    @rinej
    Contributor

    The PR with the fix was merged couple of days ago -> #92938

  16. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Jun 27, 2026
  17. melvin-bot commented on Jun 27, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. mallenexpensify commented on Jun 28, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @nyomanjyotisa due $250 via NewDot

    ^ Test case created. Thx

  19. trjExpensify commented on Jul 6, 2026

    @trjExpensify
    Contributor

    approved $250 for @nyomanjyotisa

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 productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions