Repository navigation
Hide room creation whisper when member loses room write access - #106921
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@cretadn22 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] |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@Pujan92 is the C+ reviewer for this |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 540bcc7e2b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const isIncremental = !!(reportActionsUpdates ?? reportUpdates ?? reportNameValuePairsUpdates ?? policyUpdates) && !triggeredKeys?.has(ONYXKEYS.SESSION) && !!currentValue; | ||
|
|
||
| const changedPolicyIDs = policyUpdates ? new Set(Object.keys(policyUpdates).map((key) => key.replace(ONYXKEYS.COLLECTION.POLICY, ''))) : undefined; | ||
| const policyChangedReportIDs = |
There was a problem hiding this comment.
This recomputes every report on a workspace whenever any field on that workspace changes. Workspace data changes often: category and tag edits, member list loads, and reconnects that resend every workspace. For an admin of a large workspace, that means rechecking thousands of expense reports to update one rare whisper type.
reportAttributes.ts has the same dependency and guards against this. It only recomputes reports when a relevant workspace field changed. See reportAttributes.ts.
Can you do one of these?
- Recompute only when the fields that affect room permission change:
role, the current user'semployeeListentry,type, or archived state. - When only a workspace changed, update just the
ACTIONABLE_REPORT_MENTION_WHISPERentries, not whole reports.
AI-assisted draft, reviewed and approved by @flodnv
| return false; | ||
| } | ||
| if (!canUserPerformWriteAction && isActionableWhisperRequiringWritePermission(reportAction)) { | ||
| if ((!canUserPerformWriteAction && isActionableWhisperRequiringWritePermission(reportAction)) || isActionableWhisperRequiringRoomCreationPermission(reportAction, reportID)) { |
There was a problem hiding this comment.
The cached value already includes the room permission check, so this second check is redundant. It also passes no workspace, so canCreateRoomInReport falls back to global copies of the report, workspace, and current user email.
If the global copy updates after the cached value, this can keep the whisper hidden after a member's role is restored. That's the race Codex raised. It's fixed in the cached value, but not here.
Can you drop isActionableWhisperRequiringRoomCreationPermission from this branch and rely on the cached value?
AI-assisted draft, reviewed and approved by @flodnv
| /** | ||
| * Whether the current user can create policy rooms on the workspace of the given report. | ||
| */ | ||
| function canCreateRoomInReport(reportID: string | undefined, reportParam?: OnyxEntry<Report>, policyParam?: OnyxEntry<Policy>, currentUserEmailParam?: string): boolean { |
There was a problem hiding this comment.
This is a workspace permission, not a report one. The report is only used to find its workspace. Can you move it to PolicyUtils/permissions.ts, next to canCreateExpensesOnPolicy, and have it take the workspace and login as parameters?
function canCreateRoomsOnPolicy(policy: OnyxInputOrEntry<Policy>, login: string): boolean {
return canMemberWrite(policy, login, CONST.POLICY.POLICY_FEATURE.ROOMS);
}This has two benefits:
- It removes the fallback to global data (
allPolicies,deprecatedCurrentUserEmail,getReportOrDraftReport). App prefers helpers that take their data as parameters. - Three places already write this check inline:
getPoliciesForRoomCreation,WorkspaceRoomCreatePage, andWorkspaceRoomsPage. They can use the new helper.
canMemberWrite returns false for an undefined workspace. To keep today's behavior, the visibility caller must call !policy || canCreateRoomsOnPolicy(policy, email).
AI-assisted draft, reviewed and approved by @flodnv
|
The description says the PR "subscribes AI-assisted draft, reviewed and approved by @flodnv |
twisterdotcom
left a comment
There was a problem hiding this comment.
Looks good from a product perspective.
…-mention-whisper # Conflicts: # tests/unit/ReportActionsUtilsTest.ts
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
…-room-mention-whisper
…-mention-whisper # Conflicts: # src/libs/ReportActionsUtils.ts # src/libs/actions/OnyxDerived/configs/visibleReportActions.ts # tests/unit/OnyxDerived/visibleReportActionsTest.ts
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
🚧 flodnv has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.43-0 🚀
|
|
No help site update needed — this bug fix hides the room-creation prompt from members who lack permission to create rooms, restoring expected behavior without adding a feature or making existing article text incorrect. |
|
🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.47-0 🚀
|
|
🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.51-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
When a member mentions a non-existing room in a workspace chat, Concierge posts an
ACTIONABLEREPORTMENTIONWHISPERasking whether to create that room. If the member's role on the workspace is then changed to Approve-only, they lose room write access (CONST.POLICY.POLICY_FEATURE.ROOMS), so the backend rejects room creation when they click "Yes".shouldReportActionBeVisiblepreviously checked onlycanUserPerformWriteAction(whether the user can comment in the chat), which staystruefor Approve-only members. This change checkscanCreateRoomsOnPolicyforACTIONABLEREPORTMENTIONWHISPERactions and adds thePOLICYdependency to thevisibleReportActionsderived value so the room creation whisper is hidden as soon as the member loses room write access.Fixed Issues
$ #106891
PROPOSAL:
Tests
Precondition:
Steps:
#hey).Offline tests
Same as tests.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
MacOS: Chrome / Safari
Screen.Recording.2026-11-14.at.4.05.41.PM.mov