fix: Reply in DM button not visible if no DM exists already
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.
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
⚠️ No Changeset found
Latest commit: af0a28662d12b37b5725c1034611ef5c918a5af1
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
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
canCreateDMto!canCreateDMand 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!canCreateDMshows 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 355d26d92d4d6c41b1e5ee1f82f90fde37475034 and af0a28662d12b37b5725c1034611ef5c918a5af1.
📒 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
canCreateDMto!canCreateDMproperly fixes the issue where users withcreate-dpermission couldn't see the Reply in DM button when no existing DM existed. Now:
- Users with
create-dskip this guard entirely and can always initiate a DM reply- Users without
create-dmust have an existing DM room (though see note on line 33 aboutshouldFindRoom)
33-33: Verify: Confirm the intended behavior for users withoutcreate-dpermission.The concern about logical inconsistency between
shouldFindRoom(line 33) and the!canCreateDMcheck (line 56) requires examination of the complete code flow. Specifically, howshouldFindRoomis used by downstream hooks and whether users withoutcreate-dpermission should be able to reply in existing DMs.If users without
create-dpermission 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.
Comment @coderabbitai help to get the list of available commands and usage tips.