Skip to content

[Due for payment 2025-02-27] [$250] Workspace - Admin-users are displayed in the #Admins room members list after being deleted #56525

Closed

Description

@IuliiaHerets

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.0.95-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
Issue reported by: Applause Internal Team
Device used: Mac 15.2/Safari
App Component: Workspace Settings

Action Performed:

  1. Navigate to https://staging.new.expensify.com
  2. Create a workspace, navigate to members
  3. Invite members
  4. Set some members as admins
  5. Click on the top checkbox to select all
  6. Click on the top dropdown menu > remove option
  7. Click on "Remove"
  8. Verify the users are removed from the workspace
  9. Navigate to the #Admins room
  10. Click on the header and navigate to Members

Expected Result:

Admin-users are not displayed in the #Admins room members list after being deleted from the workspace

Actual Result:

Admin-users are displayed in the #Admins room members list after being deleted from the workspace

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6735801_1738893869509.Recording__580.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021889445311434361818
  • Upwork Job ID: 1889445311434361818
  • Last Price Increase: 2025-02-11
Issue OwnerCurrent Issue Owner: @bfitzexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 7, 2025
  2. melvin-bot commented on Feb 7, 2025

    @melvin-bot

    Triggered auto assignment to @bfitzexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. bernhardoj commented on Feb 7, 2025

    @bernhardoj
    Contributor

    Proposal

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

    Removed admin is still displayed on the admins room members.

    What is the root cause of that problem?

    When we remove the member from workspace, the API still return the removed user as the member of the admins report. This is a BE issue. However, on the FE, we also don't optimistically remove the user from the admins room.

    We currently only optimistically remove the user from the announce rooms.

    const announceRoomMembers = removeOptimisticAnnounceRoomMembers(policy?.id, policy?.name ?? '', accountIDs);

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

    This should be fixed on the BE. For the optimistic part, we can create a new function called removeOptimisticAdminRoomMembers similar to removeOptimisticAnnounceRoomMembers. The logic will be the same as removeOptimisticAnnounceRoomMembers except we will get the admin room.

    const announceReport = ReportUtils.getRoom(CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE, policyID);

    To use removeOptimisticAdminRoomMembers, we will pass a filter accountIDs that only contains admin IDs.

    const adminRoomMembers = removeOptimisticAdminRoomMembers(policy?.id, policy?.name ?? '', accountIDs.filter(accountID => {
        const login = allPersonalDetails?.[accountID]?.login;
        return login && policy?.employeeList?.[login]?.role !== CONST.POLICY.ROLE.USER;
    }));
    

    This will optimistically mark the member as removed. We will need to add this when removing members (removeMembers) and updating the role.

    For role update, we will only remove if we update the role to user/member.

    if (newRole === CONST.POLICY.ROLE.USER) {
        const adminRoomMembers = removeOptimisticAdminRoomMembers(policy?.id, policy?.name ?? '', accountIDs.filter(accountID => {
            const login = allPersonalDetails?.[accountID]?.login;
            return login && policy?.employeeList?.[login]?.role !== CONST.POLICY.ROLE.USER;
        }));
        optimisticData.push(...adminRoomMembers.onyxOptimisticData);
        successData.push(...adminRoomMembers.onyxSuccessData);
        failureData.push(...adminRoomMembers.onyxFailureData);
    }
    

    I notice that we also don't optimistically add the admin to the admins room. If we would like to do it too, we can again follow a similar logic to buildAnnounceRoomMembersOnyxData. We will need to add this when adding new members and updating the role (admin/auditor).

    const announceRoomMembers = buildAnnounceRoomMembersOnyxData(policyID, accountIDs);

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can test removeMembers and assert that when removing admin, the admin is removed from the admin room. If we want to add optimistic data when adding admin too, then we need to test addMembersToWorkspace too.

  4. melvin-bot commented on Feb 10, 2025

    @melvin-bot

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

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 11, 2025
  6. changed the title [-]Workspace - Admin-users are displayed in the #Admins room members list after being deleted[/-] [+][$250] Workspace - Admin-users are displayed in the #Admins room members list after being deleted[/+] on Feb 11, 2025
  7. melvin-bot commented on Feb 11, 2025

    @melvin-bot
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 11, 2025
  9. melvin-bot commented on Feb 11, 2025

    @melvin-bot

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

  10. s77rt commented on Feb 12, 2025

    @s77rt
    Member

    @bernhardoj Thanks for the proposal. After a member is removed, the BE API response returns the correct report.participants (i.e. the removed members are removed correctly) however since the Onyx method is MERGE, the participants objects are merged and the old values persist. Do you know if this problem occurs on rooms / group chats too? We can follow the same solution

  11. 43 remaining items

  12. melvin-bot commented on Feb 20, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Feb 20, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.1-6 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-02-27. 🎊

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

    • @s77rt requires payment through NewDot Manual Requests
    • @bernhardoj requires payment through NewDot Manual Requests
  14. melvin-bot commented on Feb 20, 2025

    @melvin-bot

    @s77rt @bfitzexpensify @s77rt The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. s77rt commented on Feb 24, 2025

    @s77rt
    Member

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: n/a

    • [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.

      Bug requires regression test: Yes but let's add the test after the BE bug is fixed

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • A workspace

    Test:

    1. Go to Settings > Workspaces > Workspace > Members
    2. Invite a member as an admin
    3. Go to the #admins room
    4. Verify that the invited member is a member of the room
    5. Go to Settings > Workspaces > Workspace > Members
    6. Remove the invited member
    7. Go to the #admins room
    8. Verify that the removed member is no longer a member of the room

    Do we agree 👍 or 👎

  16. melvin-bot commented on Feb 27, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@bfitzexpensify)

    • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1889445311434361818/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  17. bernhardoj commented on Feb 27, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  18. JmillsExpensify commented on Mar 3, 2025

    @JmillsExpensify
    Contributor

    Can I get a confirmed payment summary when you get a chance @bfitzexpensify

  19. bfitzexpensify commented on Mar 4, 2025

    @bfitzexpensify
    Contributor

    Payment summary:

    Reviewer: @s77rt owed $250 via NewDot
    Reviewer: @bernhardoj owed $250 via NewDot

  20. JmillsExpensify commented on Mar 5, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @s77rt

  21. JmillsExpensify commented on Mar 5, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

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