feat: check guest availability when host reschedules a booking#27968
feat: check guest availability when host reschedules a booking#27968MrLawrenceKwan wants to merge 3 commits intocalcom:mainfrom
Conversation
When a host reschedules a booking, check if any attendees are Cal.com users. If they are, fetch their existing bookings as busy times and filter available slots accordingly. This ensures the host can only reschedule to times that work for both parties, preventing conflicts with the guest's calendar. Changes: - UserRepository: add findUsersByEmails() to look up Cal.com users - BookingRepository: add findAcceptedBookingsByUserIdsOrEmails() - getUserAvailability: accept optional guestBusyTimes in initialData - slots/util: fetch guest busy times during reschedule flow Fixes calcom#16378 /claim calcom#16378
Graphite Automations"Send notification to Community team when bounty PR opened" took an action on this PR • (02/15/26)2 teammates were notified to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/features/users/repositories/UserRepository.ts">
<violation number="1" location="packages/features/users/repositories/UserRepository.ts:289">
P2: findUsersByEmails ignores secondary emails and account status, so attendee lookups can miss valid users (secondary email) or include locked/unverified accounts in availability checks. This diverges from the established verified/secondary-email-aware lookup in the same repository and can skew reschedule availability.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const normalizedEmails = emails.map((e) => e.toLowerCase()); | ||
| return this.prismaClient.user.findMany({ | ||
| where: { | ||
| email: { in: normalizedEmails }, |
There was a problem hiding this comment.
P2: findUsersByEmails ignores secondary emails and account status, so attendee lookups can miss valid users (secondary email) or include locked/unverified accounts in availability checks. This diverges from the established verified/secondary-email-aware lookup in the same repository and can skew reschedule availability.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/users/repositories/UserRepository.ts, line 289:
<comment>findUsersByEmails ignores secondary emails and account status, so attendee lookups can miss valid users (secondary email) or include locked/unverified accounts in availability checks. This diverges from the established verified/secondary-email-aware lookup in the same repository and can skew reschedule availability.</comment>
<file context>
@@ -277,6 +277,26 @@ export class UserRepository {
+ const normalizedEmails = emails.map((e) => e.toLowerCase());
+ return this.prismaClient.user.findMany({
+ where: {
+ email: { in: normalizedEmails },
+ },
+ select: {
</file context>
MrLawrenceKwan
left a comment
There was a problem hiding this comment.
Thanks for the review! Regarding the findUsersByEmails observation:
This function intentionally does a simple primary email lookup for the reschedule guest availability check. The rationale:
- Guest emails come from the booking record — these are the emails guests used when booking, which would match their primary Cal.com email in the vast majority of cases
- False negatives are safe — if a guest's secondary email isn't matched, the reschedule simply won't check their availability (same as current behavior for non-Cal.com guests). The host can still reschedule.
- Account status filtering — locked/unverified accounts are edge cases that don't meaningfully affect availability checks for rescheduling
That said, if maintainers prefer using the verified/secondary-email-aware lookup pattern, I'm happy to update this to use findManyByEmailsWithEmailVerificationSettings instead. Let me know!
Ryukemeister
left a comment
There was a problem hiding this comment.
hi there, thanks for your contribution. can you please add relevant e2e tests for the PR, also attaching a visual demo would be really helpful. thanks!
- Test guest availability checking when host reschedules - Test blocking of conflicting time slots - Test with multiple guests (Cal.com users + external) - Test exclusion of original booking from busy times - Addresses maintainer feedback on PR calcom#27968
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/web/playwright/reschedule-guest-availability.e2e.ts">
<violation number="1" location="apps/web/playwright/reschedule-guest-availability.e2e.ts:82">
P1: Rule violated: **E2E Tests Best Practices**
Add `expect(page).toHaveURL(...)` after navigation. The E2E best practices require URL assertions to fail fast when unexpected redirects occur, and these new tests call `page.goto` without validating the URL.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
Thanks for the review @Ryukemeister — I've now addressed your request:
Also confirmed expected behavior for reschedule flow:
Happy to iterate further if you'd like any specific scenario added. |
|
(Quick correction to my previous comment) E2E file path added:
Thanks! |
|
Updated demo note: using the latest recording captured on 2026-02-17 04:42 AWST (today), duration ~3m18s. Video link: |
|
Follow-up update: addressed cubic's E2E navigation suggestion by adding URL assertions after each reschedule in (commit: f2d4b53). |
|
Correction to previous message: Addressed cubic's E2E navigation suggestion by adding URL assertions after each reschedule navigation call in:
Commit: f2d4b53 |
|
Thanks for flagging this — I have uploaded a new copy and shared an accessible link: If this still does not open from your side, I can also attach the video directly in a PR comment as a fallback. |

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)
Design decisions
Files changed (5 files)
E2E coverage added
Added end-to-end coverage for host reschedule + guest availability in:
apps/web/playwright/reschedule-guest-availability.e2e.tsScenarios covered:
Visual demo
/claim #16378
Fixes #16378