What does this PR do?
When a host reschedules a booking, this PR checks if any attendees (guests) are Cal.com users. If they are, their existing bookings are fetched as busy times and included in the available slots calculation — ensuring the host can only reschedule to times that work for both parties.
Problem
Currently, when a host reschedules, the system doesn’t check the guest’s availability. If the guest is a Cal.com user, this can result in scheduling conflicts.
Solution (minimal, focused changes)
- UserRepository.findUsersByEmails() — Looks up Cal.com users by attendee emails
- BookingRepository.findAcceptedBookingsByUserIdsOrEmails() — Fetches accepted bookings for those users within the date range
- getUserAvailability — Accepts optional guestBusyTimes in initialData
- slots/util.ts — Orchestrates the flow: when rescheduleUid is present, fetches guest busy times and passes them through
Design decisions
- Graceful degradation: If guest availability lookup fails, rescheduling still works (logged as warning)
- Only Cal.com users: Non-Cal.com guests are skipped (we cannot check their calendar)
- Excludes current booking: The booking being rescheduled is excluded from busy time calculation
- No UI changes: The existing reschedule UI automatically respects the filtered slots
Files changed (5 files)
- packages/features/users/repositories/UserRepository.ts
- packages/features/bookings/repositories/BookingRepository.ts
- packages/features/availability/lib/getUserAvailability.ts
- packages/trpc/server/routers/viewer/slots/util.ts
- apps/web/playwright/reschedule-guest-availability.e2e.ts
E2E coverage added
Added end-to-end coverage for host reschedule + guest availability in:
apps/web/playwright/reschedule-guest-availability.e2e.ts
Scenarios covered:
- Guest conflict blocks conflicting slots
- All guests available allows successful reschedule
- External (non-Cal.com) guest does not affect reschedule
- Multiple guests (mixed Cal.com + external)
- Original booking is excluded from self-conflict during reschedule
Visual demo
/claim #16378
Fixes #16378