Skip to content

[Due for payment 2026-03-25][$250] [Performance] Remove duplicate call to useLoadingBarVisibility #85428

Closed

Description

@luacmartins

Remove duplicate useLoadingBarVisibility() from TopBar.

Both SearchSidebar and TopBar independently subscribed to the same Onyx keys (PERSISTED_REQUESTS, PERSISTED_ONGOING_REQUESTS). Now TopBar receives the value via prop; callers that relied on the internal fallback (BaseSidebarScreen, InitialSettingsPage, WorkspacesListPage) pass it explicitly.

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022033574600145585267
  • Upwork Job ID: 2033574600145585267
  • Last Price Increase: 2026-03-16

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 16, 2026
  2. MelvinBot commented on Mar 16, 2026

    @MelvinBot
    Contributor

    Proposal

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

    On wide layouts, SearchSidebar and screens like BaseSidebarScreen (Inbox) can be mounted simultaneously. Both independently subscribe to the same Onyx keys (PERSISTED_REQUESTS and PERSISTED_ONGOING_REQUESTS) via separate calls to useLoadingBarVisibility() — one inside SearchSidebar and one inside TopBarWithLoadingBar (which wraps TopBar). This creates duplicate Onyx subscriptions and unnecessary re-renders.

    What is the root cause of that problem?

    TopBarWithLoadingBar (App/src/components/Navigation/TopBarWithLoadingBar.tsx) is a convenience wrapper that internally calls useLoadingBarVisibility() and passes the result to TopBar via the shouldShowLoadingBar prop. Three callers use this wrapper:

    • BaseSidebarScreen (App/src/pages/inbox/sidebar/BaseSidebarScreen.tsx:56-60)
    • InitialSettingsPage (App/src/pages/settings/InitialSettingsPage.tsx:563-567)
    • WorkspacesListPage (App/src/pages/workspace/WorkspacesListPage.tsx:739-744)

    Meanwhile, SearchSidebar and SearchPageNarrow already use TopBar directly and call useLoadingBarVisibility() at the caller level, passing the result as a prop. When a screen using TopBarWithLoadingBar is mounted alongside SearchSidebar (wide layout), both create their own subscriptions to the same two Onyx keys, resulting in redundant work.

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

    1. Update the three callers (BaseSidebarScreen, InitialSettingsPage, WorkspacesListPage) to import and call useLoadingBarVisibility() themselves, then use TopBar directly instead of TopBarWithLoadingBar, passing the result as the shouldShowLoadingBar prop.

    2. Delete TopBarWithLoadingBar (App/src/components/Navigation/TopBarWithLoadingBar.tsx) since it will no longer have any consumers.

    This follows the same pattern already used by SearchSidebar and SearchPageNarrow, where the caller owns the hook call and passes the value down as a prop to TopBar.

    What alternative solutions did you explore? (Optional)

    An alternative would be to lift useLoadingBarVisibility() to a shared context/provider so all components read from a single subscription. However, that adds architectural complexity for what is effectively a simple prop-drilling fix. The caller-owns-the-hook pattern is already established in SearchSidebar and SearchPageNarrow, so extending it to the three remaining callers is the simplest and most consistent approach.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Mar 16, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 16, 2026
  5. melvin-bot commented on Mar 16, 2026

    @melvin-bot

    Current assignee @jjcoffee is eligible for the External assigner, not assigning anyone new.

  6. changed the title [-][Performance] Remove duplicate call to useLoadingBarVisibility[/-] [+][$250] [Performance] Remove duplicate call to useLoadingBarVisibility[/+] on Mar 16, 2026
  7. melvin-bot commented on Mar 16, 2026

    @melvin-bot
  8. AbdulMoiz-Ali commented on Mar 16, 2026

    @AbdulMoiz-Ali

    Proposal

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

    On wide layouts, SearchSidebar and screens like BaseSidebarScreen (Inbox) are mounted simultaneously. Both independently subscribe to the same Onyx keys (PERSISTED_REQUESTS and PERSISTED_ONGOING_REQUESTS) via separate calls to useLoadingBarVisibility() — one inside SearchSidebar and one inside TopBarWithLoadingBar (which wraps TopBar). This creates duplicate Onyx subscriptions and unnecessary re-renders.

    What is the root cause of that problem?

    TopBarWithLoadingBar (App/src/components/Navigation/TopBarWithLoadingBar.tsx) is a wrapper that internally calls useLoadingBarVisibility() and passes the result to TopBar via the shouldShowLoadingBar prop. Three callers use this wrapper:

    • BaseSidebarScreen (App/src/pages/Inbox/sidebar/BaseSidebarScreen.tsx)
    • InitialSettingsPage (App/src/pages/settings/InitialSettingsPage.tsx)
    • WorkspacesListPage (App/src/pages/workspace/WorkspacesListPage.tsx)

    Meanwhile, SearchSidebar and SearchPageNarrow already call useLoadingBarVisibility() at the caller level and pass the result as a prop to TopBar directly. This inconsistency means the TopBarWithLoadingBar wrapper is the source of the duplicate subscriptions.

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

    1. Update the three callers (BaseSidebarScreen, InitialSettingsPage, WorkspacesListPage) to:

      • Import and call useLoadingBarVisibility() directly
      • Replace TopBarWithLoadingBar with TopBar, passing the result via the shouldShowLoadingBar prop
    2. Delete TopBarWithLoadingBar (App/src/components/Navigation/TopBarWithLoadingBar.tsx) since it will have no remaining consumers.

    This aligns all callers with the pattern already established by SearchSidebar and SearchPageNarrow, where the caller owns the hook call and passes the value down as a prop.

    What alternative solutions did you explore? (Optional)

    • Lifting useLoadingBarVisibility() to a shared context/provider so all components read from a single subscription. However, this adds architectural complexity for what is effectively a simple prop-drilling fix. The caller-owns-the-hook pattern is already established, so extending it to the three remaining callers is the simplest and most consistent approach.
  9. 21 remaining items

  10. buyuan-dev commented on Mar 20, 2026

    @buyuan-dev

    I'd like to work on this performance fix. I'll remove the duplicate useLoadingBarVisibility() call from TopBar and update callers to pass the value via props. Expected completion: 1-2 hours.

  11. melvin-bot commented on Mar 20, 2026

    @melvin-bot

    📣 @buyuan-dev! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  12. buyuan-dev commented on Mar 20, 2026

    @buyuan-dev
  13. jjcoffee commented on Mar 20, 2026

    @jjcoffee
    Contributor

    @buyuan-dev This issue is not open for proposals - note that there is no Help wanted label. Please refrain from opening PRs without being assigned and ensure you read our contributing guide to understand how you can positively contribute to the project.

  14. melvin-bot commented on Mar 23, 2026

    @melvin-bot

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

  15. melvin-bot commented on Mar 23, 2026

    @melvin-bot

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

  16. jjcoffee commented on Mar 24, 2026

    @jjcoffee
    Contributor

    Noting that no checklist or regression test is required here as this was just a performance refactor.

  17. mallenexpensify commented on Mar 25, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @jjcoffee due $250 via NewDot

  18. JmillsExpensify commented on Mar 29, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @jjcoffee

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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions