fix: restore listWithTeam query to include team events with userId set and add comprehensive tests#27752
Merged
keithwillcode merged 1 commit intomainfrom Feb 9, 2026
Conversation
…t and add comprehensive tests Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
keithwillcode
approved these changes
Feb 9, 2026
Contributor
|
Ran |
emrysal
approved these changes
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a behavioral regression introduced in #27497 where the
listWithTeamSQL query was changed to addAND "public"."EventType"."teamId" IS NULLto the first part of the UNION. This caused team event types withuserIdset (but no correspondingMembershiprow) to silently disappear from query results.This PR:
teamId IS NULLfilter from Part 1 of the UNION, restoring the original behavior where all event types withuserId = currentUserare returned (including team events where the user is the owner).LEFT JOIN usersto Part 2 of the UNION so both parts produce identicalusernamevalues for overlapping events, ensuringUNIONdeduplication works correctly.Key scenarios now tested
userIdset, user has noMembershipuserId) and team member (Membership)parentIdset,teamIdnull)userId(discovered viaMembership)usernamefield populated for individual, null for team eventsMandatory Tasks (DO NOT REMOVE)
How should this be tested?
TZ=UTC VITEST_MODE=integration yarn test listWithTeam.handler.integration-test.ts"should return team event types where userId is set but user has no membership"— this is the regression test"should not duplicate events when user is both owner and team member"— validates UNION dedupHuman Review Checklist
usersonEventType.userId, so overlapping rows produce identicalusernamevalues and are correctly dedupedteamId IS NULLfrom Part 1 doesn't produce unexpected results for other consumers (useEventTypeshook in bookings, atoms API controller)Link to Devin run: https://app.devin.ai/sessions/db3ea4a75b23410080df845007f47c56
Requested by: @Ryukemeister