Skip to content

[$250] Reduce forced focus mode switching #84056

Closed

Description

@puneetlath

Slack Thread Context: https://expensify.slack.com/archives/C05LX9D6E07/p1771328820064029?thread_ts=1771328820.064029&cid=C05LX9D6E07

What the problem is:
Users are being automatically switched into #focus mode (an unread-only filter) in a way that feels jarring and confusing, causing chats to “disappear” from the Inbox during normal navigation.

What the expected output is:

  • Reduce accidental/over-eager auto-switching by basing the threshold on the number of reports visible in the user’s LHN (not total reports in Onyx), so fewer users are forced into the mode.

Debugging info:

  • Reference: https://fsty.io/v/Cw5YnkdF
  • Current logic described: auto-switch triggers when a user has 20+ reports in Onyx, rather than 20+ reports in LHN.
  • Example mentioned: user had 6 reports in LHN but still got switched.
  • User impact reported: confusion that chats disappear after clicking into them and then navigating elsewhere; consistent negative feedback.

Potential solutions or implementation notes (if applicable):

  • First step agreed: change threshold calculation to use LHN report count instead of Onyx report count.
Issue OwnerCurrent Issue Owner: @ShridharGoel
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022028892030546284710
  • Upwork Job ID: 2028892030546284710
  • Last Price Increase: 2026-03-03

Activity

  1. self-assigned this
    on Mar 3, 2026
  2. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    Proposal

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

    Users are being automatically switched into #focus mode (GSD / unread-only filter) even when they have very few reports visible in the LHN. This causes chats to "disappear" from the Inbox during normal navigation, creating a jarring and confusing experience. The issue reports a user with only 6 reports in LHN who was still auto-switched.

    What is the root cause of that problem?

    The auto-switch logic in PriorityModeController counts all reports in Onyx where the user is a participant, owner, or manager — not the reports actually visible in the LHN.

    The counting code (line 40-50) iterates over every report in ONYXKEYS.COLLECTION.REPORT and only applies two extremely permissive filters:

    1. isValidReport (ReportUtils.ts:10482-10484) — only checks !!report?.reportID, so any report with an ID passes.
    2. isReportParticipant (ReportUtils.ts:10489-10502) — checks if the user is in participants, ownerAccountID, or managerID.

    This count includes expense reports, archived reports, hidden reports, one-transaction thread reports, system chats, and many other report types that are never displayed in the LHN. When this raw count reaches 30 (CONST.REPORT.MAX_COUNT_BEFORE_FOCUS_UPDATE), the user is auto-switched to focus mode.

    In contrast, the LHN display uses shouldReportBeInOptionList (ReportUtils.ts) which applies extensive filtering — excluding empty chats, one-transaction threads, inaccessible reports, hidden reports, and more. This creates a large gap between "reports in Onyx" and "reports visible in LHN," causing users with few visible reports to be unexpectedly switched.

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

    Modify the validReportCount calculation in PriorityModeController (src/components/PriorityModeController.tsx:40-50) to count only reports that would actually appear in the LHN in default mode (non-focus mode), rather than counting all Onyx reports.

    The existing LHN filtering logic in shouldReportBeInOptionList (in ReportUtils.ts) already determines whether a report should appear in the LHN. The PriorityModeController should use this same filtering (specifically the default-mode path, not the focus-mode path) when computing its count. This way, the threshold of 30 reports would apply to reports the user can actually see, matching the user's perception of their inbox size.

    Key consideration: shouldReportBeInOptionList requires several additional parameters (policies, betas, report actions, etc.). The controller would need to subscribe to these additional Onyx keys, or a helper function could be extracted that provides the necessary LHN-visible count. Performance should be considered since this runs on every report change — but it only needs to run until the threshold check completes (the hasSwitched ref and hasTriedFocusMode NVP prevent re-evaluation after the first switch).

    What alternative solutions did you explore? (Optional)

    1. Lowering the threshold constant — Would reduce the number of affected users but doesn't fix the fundamental mismatch. Users with few LHN reports could still be switched.
    2. Adding more exclusion filters to the existing count (e.g., excluding expense reports, archived reports) — Partial fix that would narrow the gap but wouldn't fully align with LHN visibility. Would require ongoing maintenance as new report types are added.
    3. Using getOrderedReportIDs from SidebarUtils — This computes the full ordered list for the LHN, which is more work than needed. Using shouldReportBeInOptionList directly is more targeted and avoids unnecessary sorting.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

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

    @melvin-bot

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

  6. changed the title [-]Reduce forced focus mode switching[/-] [+][$250] Reduce forced focus mode switching[/+] on Mar 3, 2026
  7. melvin-bot commented on Mar 3, 2026

    @melvin-bot
  8. puneetlath commented on Mar 3, 2026

    @puneetlath
    ContributorAuthor

    @ShridharGoel what do you think of Melvin's proposed approach?

  9. openclawdwang-ship-it commented on Mar 3, 2026

    @openclawdwang-ship-it

    Proposal

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

    Users with few visible LHN reports get auto-switched to #focus mode because the threshold counts all Onyx reports, not LHN-visible ones.

    What is the root cause of that problem?

    PriorityModeController counts reports using isValidReport (just checks reportID exists) and isReportParticipant, which includes expense reports, archived reports, one-transaction threads, hidden reports, etc. that never appear in the LHN. The threshold of 30 is reached even when only 6 reports are actually visible. The LHN display path uses shouldReportBeInOptionList which applies much stricter filtering, creating a large gap between counted vs visible reports.

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

    Replace the isValidReport + isReportParticipant count in PriorityModeController.tsx (lines 40-50) with a count that uses shouldReportBeInOptionList in default mode, so the threshold of MAX_COUNT_BEFORE_FOCUS_UPDATE is checked against reports the user can actually see in the LHN. The controller will need to subscribe to additional Onyx keys (policies, betas, reportActions) that shouldReportBeInOptionList requires, but this is acceptable since the check only runs until the first switch (guarded by hasSwitched ref and hasTriedFocusMode NVP).

  10. rishisulakhe commented on Mar 3, 2026

    @rishisulakhe

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  11. github-actions commented on Mar 3, 2026

    @github-actions
    Contributor

    ⚠️ @rishisulakhe Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. ShridharGoel commented on Mar 3, 2026

    @ShridharGoel
    Contributor

    @MelvinBot

    • Using shouldReportBeInOptionList() directly in PriorityModeController will still overcount reports that are hidden from LHN. Actual LHN visibility adds extra gating in SidebarUtils for hidden reports before calling shouldReportBeInOptionList.

    • Can we make use of reportsToDisplayInLHN via useSidebarOrderedReports to prevent duplication of the calculation logic?

    Can you check and update your proposal if needed ?

  13. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    Good catch on both points — I've updated the proposal accordingly.

    Updated Proposal

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

    Users are being automatically switched into #focus mode (GSD / unread-only filter) even when they have very few reports visible in the LHN. This causes chats to "disappear" from the Inbox during normal navigation, creating a jarring and confusing experience. The issue reports a user with only 6 reports in LHN who was still auto-switched.

    What is the root cause of that problem?

    The auto-switch logic in PriorityModeController counts all reports in Onyx where the user is a participant, owner, or manager — not the reports actually visible in the LHN.

    The counting code (line 40-50) iterates over every report in ONYXKEYS.COLLECTION.REPORT and only applies two permissive filters: isValidReport (just checks !!report?.reportID) and isReportParticipant (checks participants/ownerAccountID/managerID). This count includes expense reports, archived reports, hidden reports, one-transaction threads, system chats, and many other report types that are never displayed in the LHN.

    The actual LHN display pipeline applies multiple additional filtering layers in shouldDisplayReportInLHN — excluding unsupported types, one-transaction threads, and hidden reports — before even reaching shouldReportBeInOptionList. This creates a large gap between "reports in Onyx" and "reports visible in LHN."

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

    Replace PriorityModeController's custom report counting with the existing LHN report count from the SidebarOrderedReportsContextProvider.

    PriorityModeController is already mounted as a child of SidebarOrderedReportsContextProvider inside ComposeProviders in AuthScreens.tsx (provider at line 517, controller at line 745). It can call useSidebarOrderedReportsState() and read orderedReportIDs.length to get the exact count of reports displayed in the LHN — with all filtering layers already applied (hidden reports, unsupported types, one-transaction threads, etc.), without duplicating any logic.

    Specific changes in src/components/PriorityModeController.tsx:

    1. Remove the useOnyx(ONYXKEYS.COLLECTION.REPORT) subscription (line 36) and the validReportCount useMemo (lines 40-50), along with the accountID subscription and isValidReport/isReportParticipant imports (since they're no longer needed).
    2. Add const {orderedReportIDs} = useSidebarOrderedReportsState(); and use orderedReportIDs.length in place of validReportCount for the threshold comparison at line 73.
    3. Keep the existing isLoadingReportData gate (lines 58-66) — this ensures the controller doesn't evaluate the threshold until reports are fully loaded, even though the context computes reactively from Onyx.

    This approach avoids logic duplication, stays in sync with the actual LHN display, and also removes a heavy COLLECTION.REPORT Onyx subscription from PriorityModeController (since the context already manages that subscription).

    What alternative solutions did you explore? (Optional)

    1. Using shouldReportBeInOptionList directly — As correctly pointed out by the reviewer, this would still overcount because shouldDisplayReportInLHN in SidebarUtils.ts:248-262 adds extra gating for hidden reports, unsupported types, and one-transaction threads before reaching shouldReportBeInOptionList.
    2. Using shouldDisplayReportInLHN directly — More accurate than option 1, but would duplicate the exact logic already running in SidebarOrderedReportsContextProvider, requiring duplicate Onyx subscriptions and parameters.
    3. Extending the context to expose reportsToDisplayInLHN separately — Unnecessary since orderedReportIDs.length equals the reportsToDisplayInLHN count (sorting doesn't add/remove reports).

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  14. ShridharGoel commented on Mar 3, 2026

    @ShridharGoel
    Contributor

    @MelvinBot Implement it

  15. MelvinBot commented on Mar 3, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #84074
    Please mark it as "Ready for review" when it is ready for review.

    I created this PR from an upstream branch since I don't have push access to your fork.

    To take ownership of this branch and be able to push updates, run:

    git remote add upstream https://github.com/Expensify/App.git
    git fetch upstream claude-reduceForcedFocusModeSwitching
    git checkout -b claude-reduceForcedFocusModeSwitching upstream/claude-reduceForcedFocusModeSwitching
    git push -u origin claude-reduceForcedFocusModeSwitching
    

    Then you can close this PR and open a new one from your fork.

  16. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Mar 3, 2026
  17. added
    ReviewingHas a PR in review
    and removed on Mar 3, 2026
  18. ShridharGoel commented on Mar 20, 2026

    @ShridharGoel
    Contributor

    @mallenexpensify This is due for payment

  19. mallenexpensify commented on Mar 21, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ShridharGoel due $250 via NewDot

    Thx

  20. JmillsExpensify commented on Apr 6, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @ShridharGoel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorMelvin TriageAutomatic AI Analysis of an issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions