Skip to content

[Due for payment 2025-08-07] [$125] Memoize getValidOptions across components #67032

Closed

Description

@kacper-mikolajczak

Proposal: https://expensify.slack.com/archives/C05LX9D6E07/p1753279273230309

Problem

In a few components (UserSelectPopup, NewChatPage etc.) that render options list, the getValidOptions helper is used to determine which options to display. getValidOptions is called on every option manipulation by the user (e.g. adding user to filter or newly created chat) and takes quite a lot of time to process the data.

Solution

getValidOptions can be extracted into separate useMemo that is not combined with selectedOptions (dependency that changes on each interaction).

getValidOptions uses selectedOptions to set isSelected property but in case of those lists these won't be used anyways (selection state is handled on the component level, making it redundant). What we need to take care of is to remove duplicates, which is also done by the next step in data pipeline filterAndOrderOptions (or could be added with filterSelectedOptions helper which exists in the draft PR).

Alternative solution

Memoize getValidOptions itself with memoize helper. It should persist the memoization between screen transitions, making subsequent openings of affected screens quicker (as getValidOptions will hold its memoized version and just retrieve that instead of doing it once again on mount). However, it comes with tradeoff of keeping previous arguments in memory.

PR: #66938

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021948303128396747028
  • Upwork Job ID: 1948303128396747028
  • Last Price Increase: 2025-07-24
Issue OwnerCurrent Issue Owner: @bfitzexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    NewFeatureSomething to build that is a new item.
    on Jul 24, 2025
  2. melvin-bot commented on Jul 24, 2025

    @melvin-bot
  3. changed the title [-]Memoize getValidOptions across components[/-] [+][$250] Memoize getValidOptions across components[/+] on Jul 24, 2025
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 24, 2025
  5. melvin-bot commented on Jul 24, 2025

    @melvin-bot

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

  6. melvin-bot commented on Jul 24, 2025

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

  7. 6 remaining items

  8. changed the title [-][$250] Memoize getValidOptions across components[/-] [+][Due for payment 2025-08-07] [$250] Memoize getValidOptions across components[/+] on Jul 31, 2025
  9. melvin-bot commented on Jul 31, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.87-14 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 2025-08-07. 🎊

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

  10. melvin-bot commented on Jul 31, 2025

    @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:

    • [@thesahindia] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
    • [@bfitzexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.
  11. mountiny commented on Aug 4, 2025

    @mountiny
    Contributor

    This should be ready for payment.

    $125 to @thesahindia because there were regressions in staging

  12. changed the title [-][Due for payment 2025-08-07] [$250] Memoize getValidOptions across components[/-] [+][Due for payment 2025-08-07] [$125] Memoize getValidOptions across components[/+] on Aug 4, 2025
  13. melvin-bot commented on Aug 4, 2025

    @melvin-bot

    ⚠️ Failed to update price automatically. The BZ team member will need to update the price manually in Upwork.

  14. bfitzexpensify commented on Aug 7, 2025

    @bfitzexpensify
    Contributor

    Payment summary:

    @thesahindia due $125 via NewDot manual request

  15. twisterdotcom commented on Sep 3, 2025

    @twisterdotcom
    Contributor

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

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

    Zapier Logs Run ID: 00040eee-86f8-a823-53e8-f518ed7eaeb1
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 contributorNewFeatureSomething to build that is a new item.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions