Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$250] Workspace - Admin-users are displayed in the #Admins room members list after being deleted #56525

Open
4 of 8 tasks
IuliiaHerets opened this issue Feb 7, 2025 · 5 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Feb 7, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] 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: @s77rt
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 7, 2025
Copy link

melvin-bot bot commented Feb 7, 2025

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.

@bernhardoj
Copy link
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.

Copy link

melvin-bot bot commented Feb 10, 2025

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

@melvin-bot melvin-bot bot added the Overdue label Feb 10, 2025
@bfitzexpensify bfitzexpensify added the External Added to denote the issue can be worked on by a contributor label Feb 11, 2025
@melvin-bot melvin-bot bot 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 Feb 11, 2025
Copy link

melvin-bot bot commented Feb 11, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021889445311434361818

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 11, 2025
Copy link

melvin-bot bot commented Feb 11, 2025

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

@melvin-bot melvin-bot bot removed the Overdue label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

4 participants