-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Optimistically add and remove members from admins room #56895
Optimistically add and remove members from admins room #56895
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. Let's just confirm whether auditors should be members of the #admins
room
src/libs/actions/Policy/Member.ts
Outdated
const adminRoomMembers = removeOptimisticRoomMembers( | ||
CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, | ||
policy?.id, | ||
policy?.name ?? '', | ||
accountIDs.filter((accountID) => { | ||
const login = allPersonalDetails?.[accountID]?.login; | ||
return login && policy?.employeeList?.[login]?.role !== CONST.POLICY.ROLE.USER; | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are AUDITOR
s members of the #admins
room too? Asking because I don't see them mentioned here https://github.com/Expensify/App?tab=readme-ov-file#workspace-admin-room
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BE adds auditor as the admins member, so I guess yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should compare with role === ADMIN || role === AUDITOR
to account for further changes in case another role is added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Updated.
src/libs/actions/Policy/Member.ts
Outdated
const adminRoomMembers = removeOptimisticRoomMembers( | ||
CONST.REPORT.CHAT_TYPE.POLICY_ADMINS, | ||
policy?.id, | ||
policy?.name ?? '', | ||
accountIDs.filter((accountID) => { | ||
const login = allPersonalDetails?.[accountID]?.login; | ||
return login && policy?.employeeList?.[login]?.role !== CONST.POLICY.ROLE.USER; | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should compare with role === ADMIN || role === AUDITOR
to account for further changes in case another role is added
describe('removeMembers', () => { | ||
it('Remove members with admin/auditor role from the #admins room', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extend the test to verify the report participants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remove onyx data doesn't change the participants.
App/src/libs/actions/Policy/Member.ts
Lines 254 to 304 in ee29bcc
announceRoomMembers.onyxOptimisticData.push( | |
{ | |
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT}${announceReport.reportID}`, | |
value: { | |
...(accountIDs.includes(sessionAccountID) | |
? { | |
statusNum: CONST.REPORT.STATUS_NUM.CLOSED, | |
stateNum: CONST.REPORT.STATE_NUM.APPROVED, | |
oldPolicyName: policyName, | |
} | |
: {}), | |
}, | |
}, | |
{ | |
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${announceReport.reportID}`, | |
value: { | |
pendingChatMembers, | |
}, | |
}, | |
); | |
announceRoomMembers.onyxFailureData.push( | |
{ | |
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT}${announceReport.reportID}`, | |
value: { | |
...(accountIDs.includes(sessionAccountID) | |
? { | |
statusNum: announceReport.statusNum, | |
stateNum: announceReport.stateNum, | |
oldPolicyName: announceReport.oldPolicyName, | |
} | |
: {}), | |
}, | |
}, | |
{ | |
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${announceReport.reportID}`, | |
value: { | |
pendingChatMembers: announceReportMetadata?.pendingChatMembers ?? null, | |
}, | |
}, | |
); | |
announceRoomMembers.onyxSuccessData.push({ | |
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${announceReport.reportID}`, | |
value: { | |
pendingChatMembers: announceReportMetadata?.pendingChatMembers ?? null, | |
}, | |
}); |
The admins are not removed optimistically Screen.Recording.2025-02-16.at.5.46.12.PM.mov |
The remove optimistic data only mark it as pending remove. The one that will really remove it should come from the BE, but BE currently doesn't do that, which is why I done my test while offline to see if the member is strikethrough-ed. |
@bernhardoj The marked to be deleted members should be filtered out from the members list. You may want to check calls to |
Are you suggesting removing the members from participants on |
No, we can keep the members in the |
If we filter it out, then we won't be able to see the member getting strikethrough (while offline). Why we want to filter it out? |
The filter should be done only when online. For ref App/src/pages/ReportParticipantsPage.tsx Lines 93 to 106 in 8aead3f
The UI should reflect the user actions immediately without the need to wait for BE response. |
The pending remove user should be hidden because of OfflineWithFeedback, so we don't need to filter it out. |
Currently they are not hidden #56895 (comment) Can you please look into that? |
They are hidden. From your video, the remove API is likely already successful, so the pending chat members are removed. asd.mp4The member doesn't reappear because there is current a BE bug where the onyx update for report use SET method. |
Ah right this is working as expected Screen.Recording.2025-02-18.at.4.22.07.PM.mov |
Can you please fix the same for changing the user role to a member? Screen.Recording.2025-02-18.at.4.23.39.PM.mov |
#54792 should handle it |
Reviewer Checklist
Screenshots/VideosAndroid: NativeBuild issues. NAB Android: mWeb Chromemweb-chrome.moviOS: Nativeios.moviOS: mWeb Safarimweb-safari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
✋ 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/iwiznia in version: 9.1.1-0 🚀
|
Explanation of Change
Fixed Issues
$ #56525
PROPOSAL: #56525 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
Prerequisite: have a workspace
While offline:
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android-emu.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4