Skip to content

Conversation

@try-catch-stack
Copy link
Contributor

@try-catch-stack try-catch-stack commented Dec 3, 2025

Proposed changes (including videos or screenshots)

This PR fixes the Reply to DM button logic which was not visible if a user did not already have a DM with the other user. It was introduced in #36217

So if a user had create-d permission but did not already have a DM with the other user, value of canReplyInDM would become false.

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an inverted logic condition in the reply-in-direct-message action. The feature's availability now correctly aligns with user permissions for direct message creation, ensuring the action is properly enabled or disabled based on account settings.

✏️ Tip: You can customize this high-level summary in your review settings.

@try-catch-stack try-catch-stack requested a review from a team as a code owner December 3, 2025 15:52
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 3, 2025

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

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

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 Dec 3, 2025

⚠️ No Changeset found

Latest commit: af0a286

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 Dec 3, 2025

Walkthrough

A guard condition in the canReplyInDM check was inverted, changing from requiring canCreateDM to requiring !canCreateDM to proceed with DM room and subscription checks. This alters when the Reply in Direct Message action becomes available based on DM creation permission.

Changes

Cohort / File(s) Summary
Message toolbar DM reply action guard logic
apps/meteor/client/components/message/toolbar/useReplyInDMAction.ts
Inverted the conditional in the canReplyInDM guard: changed from requiring canCreateDM to requiring !canCreateDM to enter the DM path, flipping when dmRoom and dmSubs presence checks are bypassed versus enforced

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Guard condition logic inversion: Verify the intent behind flipping canCreateDM to !canCreateDM and confirm it aligns with expected behavior
  • Action availability impact: Test that the Reply in Direct Message action is now enabled/disabled at the correct times
  • Related behavior: Check if this change was intentional (bug fix) or if it introduces a regression affecting user permissions

Poem

🐰 A guard stood tall, but logic flipped,
Now !canCreateDM shows its grip!
When users can't create, the path runs free,
Direct messages flow more carefully.
One small invert, one big shift to see! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing the Reply in DM button visibility issue when no DM exists, which directly matches the core logic inversion from the code summary.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 355d26d and af0a286.

📒 Files selected for processing (1)
  • apps/meteor/client/components/message/toolbar/useReplyInDMAction.ts (1 hunks)
🧰 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/components/message/toolbar/useReplyInDMAction.ts
⏰ 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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (2)
apps/meteor/client/components/message/toolbar/useReplyInDMAction.ts (2)

52-62: Fix correctly addresses the stated bug.

The inversion from canCreateDM to !canCreateDM properly fixes the issue where users with create-d permission couldn't see the Reply in DM button when no existing DM existed. Now:

  • Users with create-d skip this guard entirely and can always initiate a DM reply
  • Users without create-d must have an existing DM room (though see note on line 33 about shouldFindRoom)

33-33: Verify: Confirm the intended behavior for users without create-d permission.

The concern about logical inconsistency between shouldFindRoom (line 33) and the !canCreateDM check (line 56) requires examination of the complete code flow. Specifically, how shouldFindRoom is used by downstream hooks and whether users without create-d permission should be able to reply in existing DMs.

If users without create-d permission are intentionally blocked from reply-in-DM for all cases, the current logic is correct. If they should be able to reply in existing DMs but create new ones, the condition may need adjustment.


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.

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.

1 participant