Skip to content

Comments

refactor: remove redundant parent condition in ParentRoom#38724

Open
Khizarshah01 wants to merge 6 commits intoRocketChat:developfrom
Khizarshah01:refactor/parent-room-redundancy
Open

refactor: remove redundant parent condition in ParentRoom#38724
Khizarshah01 wants to merge 6 commits intoRocketChat:developfrom
Khizarshah01:refactor/parent-room-redundancy

Conversation

@Khizarshah01
Copy link

@Khizarshah01 Khizarshah01 commented Feb 16, 2026

Proposed changes (including videos or screenshots)

Refactors the ParentRoom.tsx component to remove redundant conditional checks.

Currently, the component calculates a parentRoomId boolean by checking (prid || (teamId && !teamMain)) and then immediately checks those same conditions individually again to decide which component to render.

Before logic

	const parentRoomId = Boolean(room.prid || (room.teamId && !room.teamMain));
	if (!parentRoomId) {
		return null;
	}
	if (room.prid) {
		return <ParentDiscussion room={room} />;
	}
	if (room.teamId && !room.teamMain) {
		return <ParentTeam room={room} />;
	}

After logic

    if (room.prid) {
		return <ParentDiscussion room={room} />;
	}
	if (room.teamId && !room.teamMain) {
		return <ParentTeam room={room} />;
	}
	return null;

This changes simplifies the logic by:

  1. Checking for prid (Discussion) first.
  2. Checking for teamId (Team Channel) second.
  3. Returning null if neither matches.

This makes the code cleaner and easier to read and removes the dead code without changing any functionality or behavior.

Steps to test or reproduce

after changes. I tested manually, nothing broke

  1. Discussion: Create a Discussion from a message. Verify the "Back to [channel_name] Channel" link appears in the header.
  2. Team Channel: navigate to a channel inside a Team. Verify the "Back to [team_name] Team" link appears in the header.
  3. Standard Room: Go to a normal public channel (e.g., #group). Verify no back link appears.

Further comments

None.

Summary by CodeRabbit

  • Refactor
    • Simplified internal component logic for improved maintainability.

Task: COMM-136

@Khizarshah01 Khizarshah01 requested a review from a team as a code owner February 16, 2026 12:29
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 16, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 8.3.0, but it targets 8.2.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2026

⚠️ No Changeset found

Latest commit: 8e4d9d1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 16, 2026

Walkthrough

Refactored the conditional logic in the ParentRoom component by removing an intermediate guard around a derived boolean (parentRoomId) and reorganizing the rendering conditions. The component now directly evaluates room.prid and room.teamId conditions without the intermediate computation, maintaining functional equivalence while simplifying the control flow.

Changes

Cohort / File(s) Summary
Logic Refactoring
apps/meteor/client/views/room/Header/ParentRoom/ParentRoom.tsx
Removed intermediate guard around parentRoomId boolean and consolidated conditional rendering logic. Component now directly falls through to render ParentDiscussion when room.prid is truthy, ParentTeam when room.teamId is truthy and not room.teamMain, or null otherwise. Functionally equivalent with simplified control flow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A guard once stood at the logic gate,
But simpler paths were surely great!
I hopped the guard out of the way,
The flow runs cleaner every day—
Same function, less delay! ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: removing redundant conditional logic in the ParentRoom component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into develop
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@Khizarshah01
Copy link
Author

PR is ready for review

@dougfabris
Copy link
Member

/jira COMM

@dougfabris dougfabris added the contrib: valid A valid contribution where maintainers will review based on priority label Feb 20, 2026
@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Feb 20, 2026
@dougfabris dougfabris added this to the 8.3.0 milestone Feb 20, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Feb 20, 2026
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.59%. Comparing base (f661fbc) to head (13cf373).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38724      +/-   ##
===========================================
+ Coverage    70.55%   70.59%   +0.04%     
===========================================
  Files         3188     3184       -4     
  Lines       112651   112523     -128     
  Branches     20400    20395       -5     
===========================================
- Hits         79476    79436      -40     
+ Misses       31114    31029      -85     
+ Partials      2061     2058       -3     
Flag Coverage Δ
unit 71.58% <ø> (+0.03%) ⬆️

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.

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

Labels

contrib: valid A valid contribution where maintainers will review based on priority 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants