Amazon Ergo 1.0 · 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 Opus 5.5.
- Gold bugs found
- 7 of 20
- Comments published
- 7
- Comments matching a bug
- 7
- Comments not matching
- 0
- Cost of this PR
- $2.901
Published comments (7)
Missing destination calendar crashes the Google Meet fallback — Events without a destination calendar now throw a `TypeError` in `EventManager.create` instead of falling back to Daily. Guard `mainHostDestinationCalendar?.integration` so the `MeetLocationType` check handles empty or `null` calendars.
deleteEvent fallback matches externalId against undefined — Cancellations without `externalCalendarId` can call Google's delete with an `undefined` calendar ID, leaving the event behind. Make the `deleteEvent` fallback select the first destination with a truthy `cal.externalId` instead of matching against `undefined`.
Organization slug condition is inverted — Organization creation and verification now behave incorrectly in both billing modes: enabling team billing writes `slug` directly, while disabling it omits the slug entirely. Restore the negated `IS_TEAM_BILLING_ENABLED` condition for `slug` and keep `requestedSlug` unchanged.
Collective event creation only matches the first destination calendar — Additional collective hosts can end up with no calendar event because `createEvent` compares every credential against only `mainHostDestinationCalendar.externalId`. Build `destinationCalendarExternalIds` from all `event.destinationCalendar` entries and use `includes(c.externalId)`, keeping the match-all fallback when empty.
Collective host calendars are dropped without a primary destination — When `evt.destinationCalendar` is `null`, the optional `push` silently discards every collected host calendar, so `EventManager` falls back to the organizer's credentials. Initialize `evt.destinationCalendar` from `teamDestinationCalendars` even when the main destination is absent.
Only the first old calendar event is deleted when merging bookings — Rescheduling or merging a collective booking leaves stale events on other hosts' calendars because the `newBookingId` cleanup handles only the first `_calendar` reference. Process the remaining `booking.references` calendar entries and delete each event with its own `credentialId` and `externalCalendarId`.
Recurring cancellation deletes organizer events instead of host events — Host calendars keep stale recurring events after cancellation, and the organizer's event may be deleted repeatedly. Iterate `updatedBookings` and select the calendar reference matching the current `credentialId`, instead of scanning `bookingToDelete.user.credentials` and using the first calendar reference.