[Bug]: Livechat GET /api/v1/livechat/department?enabled=false ignores filter and returns enabled departments

Open
#43,664 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Supriyo760 is already working on this.

Since Nov 11, 2026.

  • #43666 by @Supriyo760 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
mongodb, node.js, typescript
Domain
api, backend, databases

Research direction

Start with apps/meteor/server/api/v1/omnichannel/departments.ts and apps/meteor/server/api/v1/omnichannel/lib/departments.ts, where the issue identifies how the enabled parameter becomes a query filter. Then find or add end-to-end coverage for GET /api/v1/livechat/department?enabled=false. Done means disabled departments are returned, and the response is empty when all departments are enabled.

Written by the indexing model from the issue text.

Description

type: bug
Description:

When querying the Omnichannel departments endpoint with GET /api/v1/livechat/department?enabled=false, the enabled=false query parameter is ignored by the backend query builder. As a result, active/enabled departments are returned instead of only disabled departments.

Steps to reproduce:
  1. Create a Livechat department in Omnichannel and make sure it is enabled (enabled: true).
  2. Send an authenticated request:
    GET /api/v1/livechat/department?enabled=false
  3. Inspect the returned departments array and count.
Expected behavior:

The endpoint should only return disabled departments (enabled: false). If all departments in the workspace are enabled, it should return an empty array [] (count: 0):

{
  "departments": [],
  "count": 0,
  "offset": 0,
  "total": 0,
  "success": true
}
Actual behavior:

The enabled=false filter is ignored by the backend query builder. Rocket.Chat returns active departments (enabled: true):

WhatsApp Image 2026-11-11 at 17 17 53
{
  "departments": [
    {
      "_id": "6af442eb499c57876de2b0d4",
      "name": "Enabled Dept 1794392811642",
      "enabled": true
    }
  ],
  "count": 1,
  "offset": 0,
  "total": 1,
  "success": true
}
Server Setup Information:
  • Version of Rocket.Chat Server: 8.9.1 (reproduced on latest develop 8.x)
  • License Type: Community / Enterprise
  • Number of Users: 1
  • Operating System: Linux / Windows
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 24.22.1
  • MongoDB Version: 8.0.34
Client Setup Information
  • Desktop App or Browser Version: REST API / Chrome
  • Operating System: Windows 11
Additional context
Root Cause Analysis:
  1. In apps/meteor/server/api/v1/omnichannel/departments.ts:

    enabled: enabled === 'true',
    

    When enabled query parameter is 'false', it evaluates to false. When enabled is omitted (fetching all departments), undefined === 'true' also evaluates to false.

  2. In apps/meteor/server/api/v1/omnichannel/lib/departments.ts:

    ...(enabled && { enabled: Boolean(enabled) }),
    

    Because enabled is boolean false, JavaScript evaluates false && { enabled: ... } to false. The { enabled: false } filter is therefore completely omitted from the MongoDB query, returning all departments regardless of the requested status.

I have already verified this live on a running instance and prepared a PR with the fix and automated end-to-end test coverage.

Relevant logs:
GET /api/v1/livechat/department?enabled=false
Status: 200 OK
Departments returned: 1 (expected 0)
Department: "Enabled Dept 1794392811642" (enabled: true)
Dominant language
TypeScript
Stars
46.5k
Forks
14.1k
Avg merge
1d 21h
Merged PRs (30d)
381

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/Rocket.Chat

All issues in RocketChat/Rocket.Chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.