Prevent removal of admin and default members from workspace chats#43065
Prevent removal of admin and default members from workspace chats#43065jasperhuangg merged 12 commits intoExpensify:mainfrom
Conversation
|
@mananjadhav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@brunovjk can you fix the lint issues? I can then review the code. |
All good here @mananjadhav :D |
|
Thanks @brunovjk for fixing this. I am currently testing it now. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-prevent-admin-removal.movAndroid: mWeb Chromemweb-chrome-prevent-admin-removal.moviOS: Nativeios-prevent-admin-removal.moviOS: mWeb Safarimweb-safari-prevent-admin-removal.movMacOS: Chrome / Safariweb-prevent-admin-removal.movMacOS: Desktopdesktop-prevent-admin-removal.mov |
|
All yours @jasperhuangg :D |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 1.4.84-0 🚀
|
|
This PR is failing because of issue #35391 The issue is reproducible in: Web Screen.Recording.2024-06-16.at.6.50.53.in.the.evening.mp4 |
I'm sorry, but the test steps were wrong. I fixed it now:
reference: https://github.com/Expensify/App?tab=readme-ov-file#workspace-rooms cc: @kbecciv |
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 1.4.84-3 🚀
|
|
PR is Pass according to the new step #43065 (comment) Screen.Recording.2024-06-18.at.8.22.37.in.the.morning.mp4 |
| } | ||
| const pendingChatMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); | ||
| const isAdmin = !!(policy && policy.employeeList && details.login && policy.employeeList[details.login]?.role === CONST.POLICY.ROLE.ADMIN); | ||
| const isDisabled = (isPolicyExpenseChat && isAdmin) || accountID === session?.accountID || pendingChatMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; |
There was a problem hiding this comment.
Details
This PR addresses an issue where workspace admins and default-added-users were inadvertently selectable for removal from workspace chats. To fix this, the PR implements controls based on user roles, as documented in workspace rooms and workspace chats.
Fixed Issues
$ #35391
PROPOSAL: N/A
Pre-condition:
1. We need 4 accounts for this test:
2. Login in the app as "Workspace Creator"
3. Create a workspace
4. Go to the automatically created "Workspace Chat"
5. Go to the "Report Details"
6. Go to "Members" page > Click "Invite"
7. Invite all the other 3 accounts (
admin,member, andinvited) to the "Workspace Chat"8. Still on the "Members" page, change the
adminrole toAdministrator8. Click on the "Global Fab" > "Start Chat" > Select "#Room" tab
9. Create a "workspace-room"
10. Invite all the other 3 accounts (
admin,member, andinvited) to the "workspace-room"Tests:
1. Logged as the "Workspace Creator":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Leave" button doesn't show, as you are a "workspace admin".
iii. Go to "Members" page
iv. Verify that you cannot select/remove admin and default added members
v. Verify that you can "Invite" and "Remove" (admin cannot be removed) members
vi. Go to the "workspace-room" > Report Details page
vii. Go to "Members" page
viii. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members
2. Logged as the "Workspace Admin":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Leave" button doesn't show, as you are a "workspace admin".
iii. Go to "Members" page
iv. Verify that you cannot select/remove admin and default added members
v. Verify that you can "Invite" and "Remove" (admin cannot be removed) members
vi. Go to the "workspace-room" > Report Details page
vii. Go to "Members" page
viii. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members
3. Logged as the "Workspace Member":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Invite" button does not show.
iii. Go to "Members" page
iv. Verify that you cannot "Invite" and "Remove" members.
vii. Logged as the "Workspace Member" > Go to the "workspace-room" > Report Details page
viii. Verify that the "Invite" button does not show.
x. Go to "Members" page
xi. Verify that you can "Invite" and "Remove" (you cannot remove yourself here) members.
4. Logged as the "Workspace Chat Invited":
i. Go to the "Workspace Chat" > Report Details page
ii. Verify that the "Invite" button does not show.
iii. Go to "Members" page
iv. Verify that you cannot "Invite" and "Remove" members.
vii. Logged as the "Workspace Room Invited" > Go to the "workspace-room" > Report Details page
viii. Verify that the "Invite" button does show and you can invite members to the chat.
Offline tests
N/A
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android.-.Native.mov
Android: mWeb Chrome
Android.-.mWeb.mov
iOS: Native
MacOS.-.iOS.Native.mov
iOS: mWeb Safari
MacOS.-.iOS.mWeb.mov
MacOS: Chrome / Safari
MacOS.-.Chorme.mov
MacOS: Desktop
MacOS.-.Desktop.mov