MiniMax M3 · Balanced

fix-handle-collective-multiple-host-on-destinationcalendar-cal-com

cal.com · TypeScript · S · 30–99 lines · 6 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
2 of 9
Comments published
5
Comments matching a bug
2
Comments not matching
3
Cost of this PR
$0.221

Published comments (5)

highbugpackages/core/EventManager.ts:119

Optional-chain missing on mainHostDestinationCalendar.integration — Reading `mainHostDestinationCalendar.integration` without optional chaining crashes `EventManager.create` when the entry is absent. Add the `?.` to safely short-circuit.

mediumbugpackages/app-store/googlecalendar/lib/CalendarService.ts:254-256

updateEvent fallback returns undefined calendarId when externalCalendarId missing — The `.find` filter can never match when `externalCalendarId` is falsy, so the request ships `calendarId: undefined` and fails. Mirror `selectedCalendar`'s fallback to `mainHostDestinationCalendar?.externalId` via destructuring.

mediumbugpackages/app-store/googlecalendar/lib/CalendarService.ts:314-317

deleteEvent falls back to undefined calendar when externalCalendarId is null — The same broken `.find` in `deleteEvent` forwards `calendarId: undefined` and targets nothing. Destructure `mainHostDestinationCalendar` first and combine with `externalCalendarId`, respecting the existing `defaultCalendarId` guard.

mediumbugpackages/features/bookings/lib/handleNewBooking.ts:990-994

teamDestinationCalendars duplicates accumulate in handleNewBooking — `handleNewBooking` pushes `teamDestinationCalendars` for each member without deduping, so duplicates grow on collective events. Skip insertion when `user.destinationCalendar?.id` already exists in the array.

mediumbugpackages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts:240-242

destinationCalendar falls back to empty instead of user.destinationCalendar — Without a fallback to `bookingToReschedule.user?.destinationCalendar`, reschedule emails and webhook payloads ship `destinationCalendar: []`. Mirror the sibling handlers' pattern before defaulting to an empty array.

Gold bugs found (2)

highWhen externalCalendarId is absent, updateEvent/deleteEvent look for a destination calendar whose externalId equals that absent value, so the lookup never matches and the configured destination calendar is no longer used.
highThe Google Meet fallback reads mainHostDestinationCalendar.integration without optional chaining, so a Meet booking with a null or empty destinationCalendar throws instead of falling back to Cal Video.

Gold bugs missed (7)

highThe organization slug is now set only when team billing is enabled (inverted condition), so with billing both slug and requestedSlug are set and without billing neither is.
highOffice365 (and Lark) createEvent ignore the new credentialId argument and always use the first destination calendar, so in collective bookings other hosts' credentials target the organizer's calendar instead of their own.
highFor collective events whose organizer has no destination calendar, destinationCalendar is null and the optional push drops all other hosts' destination calendars, so those hosts never get calendar events.
highVideo booking references are now saved without their credentialId, so cancelling the booking can no longer find the video credential and the meeting is not deleted.
highCancelling all remaining occurrences of a recurring collective booking deletes only the first calendar reference of each booking, repeated once per host, so the other hosts' events stay on their calendars.
mediumIn Google createEvent, when no destination calendar matches the credentialId, the hangout-link events.patch is called with an undefined calendarId and fails, so the Meet link is not added to the event description.
mediumWhen cancelling a recurring booking with multiple calendar references, the recurring-event deletion over all remaining bookings and credentials runs once per reference, causing duplicate delete calls and errors.