Skip to content

Approve-only user can join room after leaving room offline, room disappears when online #106927

Open

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: 9.5.39-2
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #106371
Email or phone of affected tester (no customers): sdmisjdinosodjisj2@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.5 / Chrome
App Component: Chat Report View

Action Performed:

Precondition:

  • Create a Control workspace.
  • Invite User B with approve-only role.
  • Admin creates a room and invites User B to the room.
  • Perform the steps below as User B:
  1. Go to staging.new.expensify.com
  2. Open the invited room.
  3. Go offline.
  4. Click on the room header.
  5. Click Leave.
  6. Click Join.
  7. Go online.

Expected Result:

In Step 5, after leaving room offline, user should be dropped to Concierge (similar to leaving room as guest in offline mode).

Actual Result:

In Step 5, after leaving room offline, user remains in the room.
In Step 6, user can "join" the room after leaving room offline.
In Step 7, after returning online, the room disappears despite rejoining the room offline.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7313767_1794639033423.16.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Nathan Lemma
Bug ID: 7313767

Issue OwnerCurrent Issue Owner: @Pujan92

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 14, 2026
  2. applause-bot commented on Nov 14, 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/67b8a6dc5fb820c5fe626047298c1b58a4502994b1d1a35d8c928b25eff9f778

  3. melvin-bot commented on Nov 14, 2026

    @melvin-bot

    @flodnv recently merged #106371, but they are OOO right now, so I'll auto-assign someone else.

  4. melvin-bot commented on Nov 14, 2026

    @melvin-bot

    Triggered auto assignment to @luacmartins (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  5. melvin-bot commented on Nov 14, 2026

    @melvin-bot

    @flodnv you have been assigned to this deploy blocker because you reviewed the offending PR: #106371

  6. github-actions commented on Nov 14, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  7. melvin-bot commented on Nov 14, 2026

    @melvin-bot

    @ShridharGoel you have been assigned to this deploy blocker because you authored the offending PR: #106371

  8. melvin-bot commented on Nov 14, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  9. MelvinBot commented on Nov 14, 2026

    @MelvinBot
    Contributor

    🤖 Web test steps verification results: ❌ fail

    Web verification was blocked because the signed-in account has no workspaces, so the required approve-only user and invited room were unavailable—not because the reported bug was reproduced. The deploy-blocker investigation identifies Enable approve-only role assignment as the likely feature-enabling trigger (medium confidence overall): existing room-leaving logic excludes guests but not approve-only members, causing the client to retain the room offline and offer Join; recommend reverting that assignment-enabling PR for containment, then correcting restricted-room Leave/Join handling for approve-only users, while noting that existing memberships remain affected and the server-side disappearance is unverified.

    Workspaces screen showing No workspaces yet

    Step Status
    1. User B opens appSigned-in app observed, but the account could not be established as the required approve-only User B.
    ❌
    2. Open invited room and record visibilityBlocked: Workspaces shows “No workspaces yet”; the required Control workspace and invited room are unavailable.
    Workspaces screen showing No workspaces yet
    ❌
    3. Go offlineNot attempted because the required fixture is missing.
    ❌
    4. Click room headerNot attempted because the invited room is unavailable.
    ❌
    5. Leave and verify navigation to ConciergeNot attempted; offline navigation remains unverified.
    ❌
    6. Check and click Join if availableNot attempted; offline Join behavior remains unverified.
    ❌
    7. Return online and check room disappearanceNot attempted; reconnect behavior remains unverified.
    ❌

    view run · view recording

  10. cocvn157 commented on Nov 14, 2026

    @cocvn157

    Proposal

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

    When an approve-only workspace member (CONST.POLICY.ROLE.APPROVE_ONLY) is invited to a workspace room (visibility === CONST.REPORT.VISIBILITY.RESTRICTED), goes offline, and clicks Leave from the room header:

    1. Instead of removing the room and navigating to Concierge (as happens for a guest member), the user stays inside the room.
    2. The Join button appears, allowing the approve-only user to click Join while offline.
    3. Once the user returns online, the room disappears because the backend removed their membership on LeaveRoom and rejected JoinRoom for an approve-only user on a restricted room.

    What is the root cause of that problem?

    In src/libs/PolicyUtils/permissions.ts:106-113, neither CONST.POLICY.ROLE.GUEST nor CONST.POLICY.ROLE.APPROVE_ONLY has access to CONST.POLICY.POLICY_FEATURE.ROOMS. Like a guest, an approve-only member cannot browse or self-join restricted workspace rooms and only has access while explicitly invited.

    When PR #106371 enabled assigning the approve-only role, two places in the room Leave/Join flow still only checked for CONST.POLICY.ROLE.GUEST:

    1. isWorkspaceMemberLeavingWorkspaceRoom in src/libs/ReportUtils.ts:15496-15502 and src/pages/DynamicReportDetailsPage/ReportDetailsMenuLeaveItem.tsx:66-87:

      function isWorkspaceMemberLeavingWorkspaceRoom(report: OnyxEntry<Report>, isPolicyEmployee: boolean, isPolicyAdminParam: boolean, isPolicyGuestParam = false): boolean {
          if (!report) {
              return false;
          }
          const hasAccessPolicyExpenseChat = isPolicyExpenseChat(report) && (report.isOwnPolicyExpenseChat || isPolicyAdminParam);
          return (report.visibility === CONST.REPORT.VISIBILITY.RESTRICTED || hasAccessPolicyExpenseChat) && isPolicyEmployee && !isPolicyGuestParam;
      }

      Because ReportDetailsMenuLeaveItem.tsx only passes isPolicyGuest (policy?.role === CONST.POLICY.ROLE.GUEST), isWorkspaceMemberLeavingWorkspaceRoom evaluates to true for an approve-only member leaving a restricted room.
      Consequently, in leaveRoom (src/libs/actions/Report/index.ts:5909-5927, 5997-6004), optimisticData only sets notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN instead of setting reportID: null and navigating away via navigateOutOfLeavedReport.

    2. canJoinChat in src/libs/ReportUtils.ts:13439-13443:

      const policyRole = getPolicyRole(policy, currentUserEmail ?? deprecatedCurrentUserEmail);
      if (isUserCreatedPolicyRoom(report) && report?.visibility === CONST.REPORT.VISIBILITY.RESTRICTED && (!policyRole || policyRole === CONST.POLICY.ROLE.GUEST)) {
          return false;
      }

      Because canJoinChat only blocks !policyRole || policyRole === CONST.POLICY.ROLE.GUEST (instead of also blocking CONST.POLICY.ROLE.APPROVE_ONLY or checking !canMemberWrite(policy, login, CONST.POLICY.POLICY_FEATURE.ROOMS)), once notificationPreference becomes HIDDEN offline, canJoinChat returns true and surfaces the Join option.

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

    1. Add isPolicyApproveOnly helper in src/libs/PolicyUtils/permissions.ts (and re-export from src/libs/PolicyUtils/index.ts):
      const isPolicyApproveOnly = (policy: OnyxInputOrEntry<Policy>, currentUserLogin?: string): boolean =>
          getPolicyRole(policy, currentUserLogin) === CONST.POLICY.ROLE.APPROVE_ONLY;
    2. Exclude approve-only members from retaining restricted rooms on Leave:
      • In src/pages/DynamicReportDetailsPage/ReportDetailsMenuLeaveItem.tsx:66-87, pass isPolicyGuest || isPolicyApproveOnly(policy) (or pass policy / hasRestrictedRoomAccess) into isWorkspaceMemberLeavingWorkspaceRoomUtil so that when an approve-only member leaves a restricted room, isWorkspaceMemberLeavingWorkspaceRoom returns false, optimistically clearing the report (reportID: null) and navigating to Concierge/last accessed report just like a guest.
    3. Block approve-only members from joining restricted rooms in canJoinChat (src/libs/ReportUtils.ts:13440-13443):
      const policyRole = getPolicyRole(policy, currentUserEmail ?? deprecatedCurrentUserEmail);
      if (
          isUserCreatedPolicyRoom(report) &&
          report?.visibility === CONST.REPORT.VISIBILITY.RESTRICTED &&
          (!policyRole || policyRole === CONST.POLICY.ROLE.GUEST || policyRole === CONST.POLICY.ROLE.APPROVE_ONLY)
      ) {
          return false;
      }
    4. Add unit tests in tests/unit/ReportUtilsTest.ts and tests/actions/ReportTest.ts verifying that for a user with role: CONST.POLICY.ROLE.APPROVE_ONLY on a restricted workspace room:
      • isWorkspaceMemberLeavingWorkspaceRoom returns false and leaveRoom optimistically sets reportID: null and navigates away.
      • canJoinChat returns false.

    What alternative solutions did you explore?

    Checking canMemberWrite(policy, login, CONST.POLICY.POLICY_FEATURE.ROOMS) inside canJoinChat and isWorkspaceMemberLeavingWorkspaceRoom is also clean and directly aligns with ROLE_PERMISSION_BUNDLES, where GUEST and APPROVE_ONLY are the exact two roles without ROOMS permission.

  11. marcaaron commented on Nov 16, 2026

    @marcaaron
    Contributor

    Heads up, I'm going to demote this one because it seems fairly minor.

  12. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Nov 16, 2026
  13. removed their assignment
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions