Skip to content

Hide room creation whisper when member loses room write access - #106921

Merged
flodnv merged 11 commits into
Expensify:mainfrom
ShridharGoel:fix-approve-only-room-mention-whisper
Nov 19, 2026
Merged

flodnv merged 11 commits into
Expensify:mainfrom
ShridharGoel:fix-approve-only-room-mention-whisper

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When a member mentions a non-existing room in a workspace chat, Concierge posts an ACTIONABLEREPORTMENTIONWHISPER asking 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".

shouldReportActionBeVisible previously checked only canUserPerformWriteAction (whether the user can comment in the chat), which stays true for Approve-only members. This change checks canCreateRoomsOnPolicy for ACTIONABLEREPORTMENTIONWHISPER actions and adds the POLICY dependency to the visibleReportActions derived value so the room creation whisper is hidden as soon as the member loses room write access.

Fixed Issues

$ #106891
PROPOSAL:

Tests

Precondition:

  1. User A creates a Control workspace and invites User B.
  2. User B creates a second workspace and sets it as their default workspace.

Steps:

  1. As User B, open the invited workspace chat and send a non-existing room mention (e.g., #hey).
  2. Verify the room creation whisper from Concierge appears.
  3. As User A, change User B's role to Approve-only in Workspace settings > Members.
  4. As User B, check the invited workspace chat and verify the room creation whisper from Concierge disappears.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

MacOS: Chrome / Safari
Screen.Recording.2026-11-14.at.4.05.41.PM.mov

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/libs/PolicyUtils/permissions.ts 100.00% <100.00%> (ø)
src/libs/PolicyUtils/policy.ts 85.16% <100.00%> (-0.10%) ⬇️
src/libs/ReportActionsUtils.ts 86.85% <100.00%> (+<0.01%) ⬆️
.../pages/workspace/rooms/WorkspaceRoomCreatePage.tsx 0.00% <0.00%> (ø)
src/pages/workspace/rooms/WorkspaceRoomsPage.tsx 0.00% <0.00%> (ø)
...ctions/OnyxDerived/configs/visibleReportActions.ts 93.10% <90.47%> (-2.73%) ⬇️
... and 10 files with indirect coverage changes

@ShridharGoel
ShridharGoel marked this pull request as ready for review November 14, 2026 11:07
@ShridharGoel
ShridharGoel requested review from a team as code owners November 14, 2026 11:07
@melvin-bot
melvin-bot Bot requested review from cretadn22 and twisterdotcom and removed request for a team November 14, 2026 11:07
@melvin-bot

melvin-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

@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]

@melvin-bot
melvin-bot Bot removed the request for review from a team November 14, 2026 11:07
@ShridharGoel
ShridharGoel requested review from a team and Pujan92 November 14, 2026 11:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T11:29:59.952788Z 540bcc7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and flodnv and removed request for a team November 14, 2026 11:07
@melvin-bot

melvin-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

@flodnv 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team November 14, 2026 11:07
@ShridharGoel
ShridharGoel requested review from a team and removed request for cretadn22 November 14, 2026 11:07
@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team November 14, 2026 11:07
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@Pujan92 is the C+ reviewer for this

@melvin-bot
melvin-bot Bot requested review from grgia and removed request for a team November 14, 2026 11:08
@melvin-bot

melvin-bot Bot commented Nov 14, 2026

Copy link
Copy Markdown

@grgia 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]

Comment thread src/libs/ReportActionsUtils.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/libs/ReportUtils.ts Resolved
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 =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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's employeeList entry, type, or archived state.
  • When only a workspace changed, update just the ACTIONABLE_REPORT_MENTION_WHISPER entries, not whole reports.

AI-assisted draft, reviewed and approved by @flodnv

Comment thread src/libs/ReportActionsUtils.ts Outdated
return false;
}
if (!canUserPerformWriteAction && isActionableWhisperRequiringWritePermission(reportAction)) {
if ((!canUserPerformWriteAction && isActionableWhisperRequiringWritePermission(reportAction)) || isActionableWhisperRequiringRoomCreationPermission(reportAction, reportID)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/libs/ReportUtils.ts Outdated
/**
* 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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and WorkspaceRoomsPage. 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

@flodnv

flodnv commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

The description says the PR "subscribes useReportActionsVisibility to the report policy's role." The diff doesn't change that hook. The update comes from the new POLICY dependency in the visibleReportActions cached value. Can you update the Explanation of Change to match?

AI-assisted draft, reviewed and approved by @flodnv

twisterdotcom
twisterdotcom previously approved these changes Nov 16, 2026

@twisterdotcom twisterdotcom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from a product perspective.

…-mention-whisper

# Conflicts:
#	tests/unit/ReportActionsUtilsTest.ts
@melvin-bot

melvin-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@flodnv flodnv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also CI is failing

Comment thread src/libs/ReportActionsUtils.ts Resolved
…-mention-whisper

# Conflicts:
#	src/libs/ReportActionsUtils.ts
#	src/libs/actions/OnyxDerived/configs/visibleReportActions.ts
#	tests/unit/OnyxDerived/visibleReportActionsTest.ts
@ShridharGoel
ShridharGoel requested a review from flodnv November 19, 2026 14:33
@flodnv

flodnv commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@flodnv
flodnv merged commit b057ed2 into Expensify:main Nov 19, 2026
36 of 38 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 flodnv has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.43-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

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.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.47-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/flodnv in version: 9.5.51-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.51-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants