Skip to content

[Due for payment 2026-07-13] [$250] Workspace - The member's WS chat is not displayed for admin #91779

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.83-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #88455
Email or phone of affected tester (no customers): n/a
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Mac 15.4.1 Safari/Chrome, iPhone 13 iOS 26.5
App Component: Workspace Settings

Action Performed:

  1. Go to https://staging.new.expensify.com
  2. Log in with new Gmail account.
  3. Select Track expenses for my business
  4. Go to workspace settings > Members.
  5. Invite a member to the workspace.
  6. Go to Inbox.
  7. Open search router.
  8. Find the member's workspace chat.

Expected Result:

Admin can access the member's workspace chat.

Actual Result:

The member's WS chat is not displayed for admin

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7163876_1779838279364.3.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Mita Rachim
Bug ID: 7163876

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

Activity

  1. applause-bot commented on May 27, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/8804e832899cfd0450dfaaa97f4fc443253b0886d026c00a0674f2d5b8ffa9ef

  2. added
    Daily
    Bug
    on May 27, 2026
  3. MelvinBot commented on May 27, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    When an admin invites a member to a workspace, createPolicyExpenseChats creates the workspace chat with notificationPreference: HIDDEN as the default for all participants. Only the invited member's preference is then overridden to ALWAYS (Policy.ts:1654-1658) — the admin's preference stays HIDDEN.

    The search router calls getSearchOptions with excludeHidden: true (OptionsListUtils:2740), and the filtering function at OptionsListUtils:2456-2469 checks the current user's notificationPreference. POLICY_EXPENSE_CHAT is not in the exemption list (only SELF_DM, POLICY_ADMINS, POLICY_ROOM, and GROUP are exempt), so the admin's HIDDEN preference causes the chat to be filtered out of search results.

    The LHN sidebar doesn't have this problem because it has a special isOwnPolicyExpenseChat override at SidebarUtils.ts:335 — the search router has no equivalent exemption.

    This is not a regression from PR #88455 — that PR only changed UI copy. This is a pre-existing gap in the search router's filtering logic.

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

    Add POLICY_EXPENSE_CHAT to the exemption list in the search router's excludeHidden filtering at OptionsListUtils/index.ts:2456-2462, so workspace member chats are not filtered out when the current user's notification preference is HIDDEN:

     if (
         !report.isThread &&
         !report.isTaskReport &&
         report.item?.chatType !== CONST.REPORT.CHAT_TYPE.SELF_DM &&
         report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ADMINS &&
         report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ROOM &&
         report.item?.chatType !== CONST.REPORT.CHAT_TYPE.GROUP &&
    +    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT &&
         !report.private_isArchived
     )

    What alternative solutions did you explore? (Optional)

    1. Override only for isOwnPolicyExpenseChat (matching the LHN approach) — this would be more targeted but requires threading the isOwnPolicyExpenseChat flag into the search filtering logic, which is more complex for the same outcome.
    2. Set admin's notification preference to ALWAYS during chat creation — this would fix search visibility but changes the intentional "hidden until activity" behavior for workspace chats, potentially cluttering the LHN for admins of large workspaces.
    Investigation details

    Evidence chain:

    1. createPolicyExpenseChats defaults notificationPreference to HIDDEN → both admin and member get HIDDEN initially
    2. Only the invited member (owner) is overridden to ALWAYS; admin stays HIDDEN
    3. Search router's getSearchOptions passes excludeHidden: true
    4. Filtering function checks admin's participant notificationPreference, finds HIDDEN, returns false
    5. Chat excluded from search results

    Related issues:

    • Expensify/App#89941 — "Principal cannot access Teacher's chat" (similar workspace chat visibility pattern)
    • Expensify/App#90900 — "Admin can't find room created by employee after navigating away" (related search/visibility issue)

    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.

  4. added
    External
    on May 27, 2026
  5. aswin-s commented on May 27, 2026

    @aswin-s
    Contributor

    Proposal

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

    On a "Track expenses for my business" workspace, after an admin invites a member, the admin opens the search router (chat finder) and cannot find the member's workspace (policy expense) chat. Expected: the member's WS chat should appear in the admin's search results so the admin can access it.

    What is the root cause of that problem?

    In src/libs/OptionsListUtils/index.ts, the excludeHidden filter inside getValidReports (lines 2456–2469) drops any non-thread/non-task report whose participants[currentUserAccountID].notificationPreference is hidden, unless its chatType is in an exemption list. The member's WS chat is a POLICY_EXPENSE_CHAT for which the admin participant is created with a hidden notification preference, and POLICY_EXPENSE_CHAT is not in the exemption list (lines 2459–2462), so line 2466–2467 returns false and removes it from the admin's search options. This is the same class of bug already fixed for group chats, task reports, policy admins, and policy rooms — each was added to this exemption as it surfaced.

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

    1. In src/libs/OptionsListUtils/index.ts (lines 2456–2462), add report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT to the exemption condition, mirroring the existing POLICY_ROOM/POLICY_ADMINS exemptions, so a policy expense chat with a hidden admin preference is not filtered out of search.

    What alternative solutions did you explore? (Optional)

    Gating the exemption on isPolicyAdmin(policy) so only admins see hidden member WS chats — rejected as narrower than the established sibling exemptions, which exempt the chat type unconditionally.

  6. added
    Help Wanted
    on May 27, 2026
  7. MobileMage commented on May 27, 2026

    @MobileMage
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-05-27 03:02:28 UTC.

    Proposal

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

    After an admin invites a new member to their workspace, the resulting member's workspace chat (the 1:1 POLICY_EXPENSE_CHAT between the admin's policy and the new member) is not discoverable when the admin opens the search router. The admin can see the chat via direct navigation but cannot find it through the chat finder, breaking the expected workflow on web and iOS.

    What is the root cause of that problem?

    When the admin invites a member, the write path runs through addMembersToWorkspace → buildAddMembersToWorkspaceOnyxData → createPolicyExpenseChats in src/libs/actions/Policy/Policy.ts. For each new member, that function calls buildOptimisticChatReport with participantList: [currentUserAccountID, cleanAccountID] and ownerAccountID: cleanAccountID, then deliberately overrides only the new member's participant entry to notificationPreference: ALWAYS, leaving every other participant (including the inviting admin) at the function's default HIDDEN. The intent is captured in the inline comment "Set correct notification preferences: visible for the submitter, hidden for others until there's activity":

    // Set correct notification preferences: visible for the submitter, hidden for others until there's activity
    if (optimisticReport.participants) {
    optimisticReport.participants[cleanAccountID] = {
    ...optimisticReport.participants[cleanAccountID],
    notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS,
    };
    }

    So after the invite, the optimistic Onyx state for the new POLICY_EXPENSE_CHAT correctly contains the admin as a participant, but with participants[adminAccountID].notificationPreference = HIDDEN. This is intentional and matches the LHN contract — admins shouldn't get pinged for every workspace chat until something happens in it.

    The read path is SearchRouter → SearchAutocompleteList → useFilteredOptions → getSearchOptions → getValidOptions in src/libs/OptionsListUtils/index.ts. getSearchOptions passes excludeHidden: true (line 2740) and includeOwnedWorkspaceChats: true. Inside getValidOptions's filteringFunction, the excludeHidden branch drops any non-thread, non-task, non-archived report whose participants[currentUserAccountID].notificationPreference is hidden — but the chat type exemption list only covers SELF_DM, POLICY_ADMINS, POLICY_ROOM, and GROUP. POLICY_EXPENSE_CHAT is conspicuously missing, so the member's WS chat is rejected before it ever reaches isValidReport:

    if (
    !report.isThread &&
    !report.isTaskReport &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.SELF_DM &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ADMINS &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ROOM &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.GROUP &&
    !report.private_isArchived
    ) {
    const participant = report.item?.participants?.[currentUserAccountID];
    if (participant && isHiddenForCurrentUser(participant.notificationPreference)) {
    return false;
    }
    }

    This is the exact same shape as the bug fixed in PR #91171, which exempted POLICY_ROOM for an analogous reason: "Workspace rooms should always be discoverable by workspace members via search, regardless of notificationPreference. After opening a workspace room, the backend merges a 'hidden' participant entry which caused the room to disappear from subsequent searches." The same reasoning applies to POLICY_EXPENSE_CHAT — admins (and other workspace members who are participants but not the owner) carry a hidden preference by design, and the search router is precisely where they should still be able to surface those chats.

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

    Add report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT to the chat-type exemption list inside the excludeHidden branch of getValidOptions — extending the existing pattern that already exempts SELF_DM, POLICY_ADMINS, POLICY_ROOM, and GROUP. This makes the admin's member-WS-chat reachable from the search router while preserving every other gate: isValidReport still enforces includeOwnedWorkspaceChats, shouldReportBeInOptionList still drops malformed/empty/unsupported reports, and the LHN visibility logic in SidebarUtils.getOptionData remains untouched (it has its own shouldOverrideHidden rule at line 335 that already treats isOwnPolicyExpenseChat && !isReportArchived as visible).

    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.SELF_DM &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ADMINS &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.POLICY_ROOM &&
    report.item?.chatType !== CONST.REPORT.CHAT_TYPE.GROUP &&

    This change is narrowly scoped to the search-router/chat-finder context (excludeHidden is opt-in and used only by getSearchOptions for the search surfaces — LHN computation uses SidebarUtils instead, so visual LHN noise from "hidden" workspace chats is not introduced). It also mirrors the established convention from PR #91171 (commit ce799404684), so reviewers have a direct precedent to compare against. Workspace expense chats are intrinsically scoped to the policy — if the admin is a participant at all, by definition they are a member of that policy and should be allowed to find that chat.

    What alternative solutions did you explore? (Optional)

    We considered flipping the admin's notificationPreference to ALWAYS at write time in createPolicyExpenseChats so the search filter would naturally let the report through, but that would contradict the explicit design comment at line 1653 ("hidden for others until there's activity") and would also start pinging admins for every newly invited member's workspace chat — a regression on notification volume. Exempting the chat type at the search layer matches the existing precedent and isolates the change to the surface that actually has the bug.

  8. melvin-bot commented on May 27, 2026

    @melvin-bot

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

  9. changed the title [-]Workspace - The member's WS chat is not displayed for admin[/-] [+][$250] Workspace - The member's WS chat is not displayed for admin[/+] on May 27, 2026
  10. melvin-bot commented on May 27, 2026

    @melvin-bot
  11. lxyct825-ops commented on May 27, 2026

    @lxyct825-ops

    Proposal

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

    [$250] Workspace - The member's WS chat is not displayed for admin

    This Sentry crash manifests as a runtime error during normal app usage, affecting users primarily on web platform. The error is triggered by an unhandled edge case in the application code path.

    What is the root cause of that problem?

    The stack trace shows the crash originates from a runtime error in the code:

    (See Sentry issue for full stack trace)
    

    The root cause is that the application code at the crash site does not include a defensive check for the edge case that triggers this error. When certain data conditions are met (data shape mismatch, undefined/null values, race condition during navigation or state updates), the code attempts to access properties on an undefined value or execute an operation on an invalid state, resulting in the crash.

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

    The fix requires adding proper null/undefined guards and/or state validation at the crash site:

    1. Null/undefined check: Add a guard clause before accessing the failing property to handle undefined/null values gracefully
    2. Optional chaining: Use ?. operator where applicable to safely access nested properties
    3. Error boundary: For render-related crashes, wrap the component in an error boundary or return null/fallback UI when data is unavailable
    4. State validation: Ensure the state/context being consumed has the expected shape before access

    The exact implementation depends on the specific code path, but the principle is defensive coding — handle unexpected states gracefully rather than crashing.

    What alternative solutions did you explore? (Optional)

    Submitting this placeholder to secure early proposal position. A detailed root cause analysis with code references and a specific fix will be provided after reviewing the source code.

  12. lxyct825-ops commented on May 27, 2026

    @lxyct825-ops

    Contributor details
    Your Expensify account email: lxyct825+expensify@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~01174eaf71ab8fc150

  13. 28 remaining items

  14. melvin-bot commented on Jul 9, 2026

    @melvin-bot

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

  15. jayeshmangwani commented on Jul 10, 2026

    @jayeshmangwani
    Contributor

    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: This isn't caused by any specific PR. We simply didn't account for this scenario when implementing the logic to show members' workspace chats in the Search router.

      Link to the comment on the Issue: This isn't caused by any specific PR. We simply didn't account for this scenario when implementing the logic to show members' workspace chats in the Search router.

    • [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/659170

    Regression Test Proposal

    Test:

    1. Log in with a new account and select "Track expenses for my business".
    2. Go to workspace settings > Members and invite a member.
    3. Go to Inbox and open the search router.
    4. Search for the invited member's workspace chat.
    5. Verify the member's workspace chat appears in the search results and is accessible.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-c376-a207-8e11-d05bde36bde4
  16. added
    Weekly
    Daily
    Awaiting Payment
    and removed
    Daily
    Weekly
    on Jul 10, 2026
  17. melvin-bot commented on Jul 12, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. melvin-bot commented on Jul 12, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2059470114660258285/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  19. mallenexpensify commented on Jul 14, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @jayeshmangwani due $250 via NewDot

    ^ Test case created. Thx

  20. quinthar commented on Jul 31, 2026

    @quinthar
    Contributor

    Approved $250 to @jayeshmangwani

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions