Skip to content

fix: own account showing twice in navbar room search when searching by username - #41152

Merged
dionisio-bot[bot] merged 6 commits into
developfrom
fix/duplicate-own-account-room-search
Jul 6, 2026
Merged

fix: own account showing twice in navbar room search when searching by username#41152
dionisio-bot[bot] merged 6 commits into
developfrom
fix/duplicate-own-account-room-search

Conversation

@nazabucciarelli

@nazabucciarelli nazabucciarelli commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Filter out own DMs from local rooms. Previously we were only removing duplicate of DMs with only two members (room.uids.length === 2 condition in sameDirectDM).

Issue(s)

SUP-1069 Own account shows twice in navbar user search when searching by username (self DM duplicate)

Steps to test or reproduce

  1. Log in as any user.
  2. Create a DM with yourself.
  3. Open the navbar search.
  4. Search for your own username (not display name).
  5. Your account is listed twice in the dropdown.
  6. Open either entry: both open the same direct message with yourself.

Further comments

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Fixed navbar room search so your own account no longer appears twice when searching by username.
    • Improved navbar search result merging by better deduplicating direct-message results representing the same DM user.
  • Tests

    • Added Jest coverage for the navbar search hook to verify both deduped (duplicate DM user) and appended (non-duplicate) results.

@dionisio-bot

dionisio-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ff2de6b

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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

@nazabucciarelli nazabucciarelli added this to the 8.7.0 milestone Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 38c50fbb-f201-4d74-8521-817671e85562

📥 Commits

Reviewing files that changed from the base of the PR and between 9de94f5 and ff2de6b.

📒 Files selected for processing (1)
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
⚠️ CI failures not shown inline (2)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

Walkthrough

This PR fixes duplicate self-account entries in navbar room search by treating matching direct-message names as duplicates. It adds hook coverage for duplicate and non-duplicate spotlight results and includes a patch changeset.

Changes

Navbar search dedupe fix

Layer / File(s) Summary
Dedupe logic update
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
Extends the local duplicate check to compare direct-message item names with the local room name.
Tests and changeset
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.ts, .changeset/breezy-moons-search.md
Adds hook tests covering duplicate and appended spotlight results, and a patch changeset entry documenting the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: ggazzo

🚥 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 matches the main fix: preventing the user’s own account from appearing twice in navbar room search by username.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SUP-1069: 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.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.30%. Comparing base (2f28c1c) to head (ff2de6b).
⚠️ Report is 45 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41152      +/-   ##
===========================================
+ Coverage    69.12%   69.30%   +0.17%     
===========================================
  Files         3433     3539     +106     
  Lines       132444   138946    +6502     
  Branches     23118    24801    +1683     
===========================================
+ Hits         91546    96290    +4744     
- Misses       37526    38645    +1119     
- Partials      3372     4011     +639     
Flag Coverage Δ
e2e 59.33% <100.00%> (-0.03%) ⬇️
e2e-api 49.83% <ø> (+9.43%) ⬆️
unit 70.16% <100.00%> (+0.19%) ⬆️

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.

@nazabucciarelli
nazabucciarelli marked this pull request as ready for review July 2, 2026 20:34
@nazabucciarelli
nazabucciarelli requested a review from a team as a code owner July 2, 2026 20:34

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx (1)

29-76: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a regression test for the existing two-party DM dedupe path.

Only the new self-DM (sameUserDM) and non-duplicate paths are covered. The pre-existing sameGroupDM/sameDirectDM branches in isLocalDuplicate aren't exercised by any test in this file, so a future change to the predicate could silently break dedup for regular (non-self) DMs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx` around
lines 29 - 76, Add a regression test in useSearchItems.spec.tsx to cover the
existing two-party DM dedupe path in useSearchItems/isLocalDuplicate. The
current tests only verify self-DM and non-duplicate server user behavior, so add
a case that seeds useUserSubscriptions with a local direct message room for
another user and mock getSpotlight to return the same user from the server, then
assert useSearchItems keeps the local room and does not append a duplicate.
Reference the sameDirectDM and sameGroupDM branches in isLocalDuplicate when
locating the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx`:
- Around line 29-76: Add a regression test in useSearchItems.spec.tsx to cover
the existing two-party DM dedupe path in useSearchItems/isLocalDuplicate. The
current tests only verify self-DM and non-duplicate server user behavior, so add
a case that seeds useUserSubscriptions with a local direct message room for
another user and mock getSpotlight to return the same user from the server, then
assert useSearchItems keeps the local room and does not append a duplicate.
Reference the sameDirectDM and sameGroupDM branches in isLocalDuplicate when
locating the logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1291045-e115-4148-b874-76239653ecab

📥 Commits

Reviewing files that changed from the base of the PR and between 6da12d7 and b5dc9b3.

📒 Files selected for processing (3)
  • .changeset/breezy-moons-search.md
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
🧠 Learnings (8)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/breezy-moons-search.md
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.tsx
  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
🔇 Additional comments (2)
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts (1)

136-142: LGTM!

.changeset/breezy-moons-search.md (1)

1-6: LGTM!

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.ts
Comment thread apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.spec.ts

@dougfabris dougfabris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@nazabucciarelli nazabucciarelli added the stat: QA assured Means it has been tested and approved by a company insider label Jul 3, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 3, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 3, 2026
@nazabucciarelli nazabucciarelli removed the stat: QA assured Means it has been tested and approved by a company insider label Jul 3, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jul 3, 2026
@nazabucciarelli nazabucciarelli added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Jul 3, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 4, 2026
@nazabucciarelli nazabucciarelli removed the stat: QA assured Means it has been tested and approved by a company insider label Jul 6, 2026
@nazabucciarelli nazabucciarelli added the stat: QA assured Means it has been tested and approved by a company insider label Jul 6, 2026
@dionisio-bot dionisio-bot Bot added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider and removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Jul 6, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 6, 2026
@nazabucciarelli nazabucciarelli removed the stat: QA assured Means it has been tested and approved by a company insider label Jul 6, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Jul 6, 2026
@nazabucciarelli nazabucciarelli added the stat: QA assured Means it has been tested and approved by a company insider label Jul 6, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 6, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 6, 2026
Merged via the queue into develop with commit 0759f83 Jul 6, 2026
116 of 122 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/duplicate-own-account-room-search branch July 6, 2026 12:06
This was referenced Jul 20, 2026
srijnabhargav added a commit to srijnabhargav/Rocket.Chat that referenced this pull request Aug 9, 2026
Rebase onto the latest GSoC base branch pulls in an unrelated upstream
fix (own account showing twice in navbar room search, RocketChat#41152) that
adds a data-tooltip attribute via a new useUserStatusTooltip hook used
by the shared Option component. Regenerate the affected snapshots to
reflect this base-branch change; no RoomMembers behavior changed.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants