Skip to content

fix: hide 'Delete all closed chats' button when user lacks remove-closed-livechat-rooms permission#40492

Merged
dionisio-bot[bot] merged 3 commits into
developfrom
cursor/hide-delete-all-closed-chats-without-permission-bb3d
May 14, 2026
Merged

fix: hide 'Delete all closed chats' button when user lacks remove-closed-livechat-rooms permission#40492
dionisio-bot[bot] merged 3 commits into
developfrom
cursor/hide-delete-all-closed-chats-without-permission-bb3d

Conversation

@MartinSchoeler
Copy link
Copy Markdown
Member

@MartinSchoeler MartinSchoeler commented May 12, 2026

Proposed changes (including videos or screenshots)

The "Delete all closed chats" menu item in the Omnichannel Contact Center kebab menu was always visible, regardless of whether the user had the remove-closed-livechat-rooms permission. While the backend correctly enforced the permission (returning error-unauthorized), the frontend did not gate the button's visibility.

This PR adds a usePermission('remove-closed-livechat-rooms') check in ChatsTableFilter.tsx to:

  • Conditionally include the "Delete all closed chats" item in the kebab menu only when the user has the permission
  • Hide the entire kebab menu ("More" button) when there are no permitted menu items

This follows the same pattern already used in ChatsTable.tsx for the single-room remove-closed-livechat-room permission check.

Unit tests are included to verify:

  • The "More" kebab menu is shown when the user has the remove-closed-livechat-rooms permission
  • The "More" kebab menu is hidden when the user lacks the permission
  • The "Delete all closed chats" menu item appears inside the menu when the permission is granted

Steps to test or reproduce

  1. Remove the remove-closed-livechat-rooms permission from all roles in Admin > Permissions
  2. Navigate to Omnichannel Contact Center > Chats tab
  3. Before fix: The kebab menu ("More") button is visible and clicking "Delete all closed chats" shows an unauthorized error
  4. After fix: The kebab menu ("More") button is hidden entirely since the only action it contained is now gated by the permission
  5. Re-add the permission to any role and verify the menu reappears with the "Delete all closed chats" option

Further comments

The change is minimal and isolated to ChatsTableFilter.tsx. Only one file is modified for the fix, adding one usePermission hook call and conditionally rendering the menu items and the menu component itself. A companion test file validates the permission gating behavior.

SUP-1031

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Restricts the "Delete all closed chats" option to users with the required permission and only shows the actions menu when there are available options.
  • Tests
    • Adds tests verifying the conditional display of the actions menu and the "Delete all closed chats" option based on permissions.
  • Chores
    • Adds a changeset noting the patch release.

Review Change Stack

…sed-livechat-rooms permission

The kebab menu item 'Delete all closed chats' in the Omnichannel Contact Center
was always visible regardless of user permissions. While the backend correctly
checked the 'remove-closed-livechat-rooms' permission and returned an error,
the frontend did not gate the button visibility on this permission.

Added usePermission('remove-closed-livechat-rooms') check to conditionally
render the menu item and hide the entire kebab menu when there are no
permitted actions.

Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 12, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb336c7a-bce4-46d9-bc80-eb6fd4bf93f3

📥 Commits

Reviewing files that changed from the base of the PR and between ceff6e3 and 6509586.

📒 Files selected for processing (1)
  • .changeset/ten-lizards-divide.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/ten-lizards-divide.md
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

Walkthrough

ChatsTableFilter now gates the "delete all closed chats" feature behind the remove-closed-livechat-rooms permission. The component checks permission on render, conditionally includes the delete action in the menu, and renders the "More" dropdown only when actions are available. Tests verify this conditional behavior.

Changes

Permission-gated delete all closed chats

Layer / File(s) Summary
Permission check and conditional rendering
apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.tsx, apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableFilter.spec.tsx, .changeset/ten-lizards-divide.md
usePermission hook is imported and invoked to check remove-closed-livechat-rooms. menuItems conditionally includes the delete-all-closed-chats action only when permitted. The "More" dropdown (GenericMenu) renders only when menuItems is non-empty. Test suite validates that the menu and delete option appear exclusively when the user has the required permission; a changeset notes the patch release.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: hiding the 'Delete all closed chats' button when users lack the required permission. It directly relates to the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SUP-1031: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 6509586

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-composer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 12, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ MartinSchoeler
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.64%. Comparing base (6b2afb3) to head (6509586).
⚠️ Report is 23 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #40492    +/-   ##
=========================================
  Coverage    69.64%   69.64%            
=========================================
  Files         3318     3323     +5     
  Lines       121981   122677   +696     
  Branches     21791    21892   +101     
=========================================
+ Hits         84948    85444   +496     
- Misses       33701    33910   +209     
+ Partials      3332     3323     -9     
Flag Coverage Δ
e2e 59.10% <66.66%> (+0.09%) ⬆️
e2e-api 46.28% <ø> (-0.06%) ⬇️
unit 70.39% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Verifies that the kebab menu with the 'Delete all closed chats' option
is only rendered when the user has the 'remove-closed-livechat-rooms'
permission, and hidden otherwise.

Co-authored-by: Martin Schoeler <martin.schoeler@rocket.chat>
@MartinSchoeler MartinSchoeler marked this pull request as ready for review May 12, 2026 17:36
@MartinSchoeler MartinSchoeler requested a review from a team as a code owner May 12, 2026 17:36
tassoevan
tassoevan previously approved these changes May 13, 2026
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label May 13, 2026
@alfredodelfabro alfredodelfabro added this to the 8.5.0 milestone May 13, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 13, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 13, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 13, 2026
@MartinSchoeler MartinSchoeler added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels May 14, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 14, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 14, 2026
@MartinSchoeler MartinSchoeler added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels May 14, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 14, 2026
Merged via the queue into develop with commit fa8413f May 14, 2026
81 of 84 checks passed
@dionisio-bot dionisio-bot Bot deleted the cursor/hide-delete-all-closed-chats-without-permission-bb3d branch May 14, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants