Skip to content

feat: Take into account guest's availability when rescheduling#27593

Closed
JarvisInvestInsight wants to merge 3 commits intocalcom:mainfrom
JarvisInvestInsight:feature/guest-availability-on-reschedule
Closed

feat: Take into account guest's availability when rescheduling#27593
JarvisInvestInsight wants to merge 3 commits intocalcom:mainfrom
JarvisInvestInsight:feature/guest-availability-on-reschedule

Conversation

@JarvisInvestInsight
Copy link
Copy Markdown

What does this PR do?

When a host reschedules a booking, this now checks if the guest (attendee) is a Cal.com user. If they are, the system fetches their availability and only shows time slots when BOTH the host AND the guest are available.

This prevents hosts from rescheduling to times when the guest is busy, improving the rescheduling experience for both parties.

Changes

  • Added _getGuestAvailabilityForReschedule\ helper method to fetch guest's Cal.com availability
  • Integrated availability intersection in _getAvailableSlots\ when
    escheduleUid\ is present
  • Properly handles edge cases:

    • ull: Guest is not a Cal.com user → show host-only availability
    • []: Guest IS a Cal.com user with NO availability → return no slots
    • [...]: Guest has availability → intersect with host
  • Gracefully handles errors (falls back to host-only availability)
  • Added comprehensive unit tests (7 test cases)

Tests Added

  • Returns null when booking not found
  • Returns null when booking has no attendees
  • Returns null when guest is not a Cal.com user
  • Returns guest availability when guest IS a Cal.com user with slots
  • Returns empty array when guest IS a Cal.com user with NO availability
  • Excludes host emails from guest list
  • Gracefully returns null on error

Video Demo

Recording in progress - will be added shortly

Closes #16378

When a host reschedules a booking, this now checks if the guest (attendee)
is a Cal.com user. If they are, the system fetches their availability and
only shows time slots when BOTH the host AND the guest are available.

This prevents hosts from rescheduling to times when the guest is busy,
improving the rescheduling experience for both parties.

Changes:
- Added _getGuestAvailabilityForReschedule helper method
- Integrated availability intersection in _getAvailableSlots
- Gracefully handles errors (falls back to host-only availability)

Closes calcom#16378
Previously, if a Cal.com user (guest) had NO available slots, the code
treated this the same as 'not a Cal.com user' and showed host-only
availability. This was incorrect - if the guest is a Cal.com user with
zero availability, the result should be no available slots.

Fixed by distinguishing between:
- null: Guest is not a Cal.com user (show host-only availability)
- []: Guest IS a Cal.com user with no availability (return no slots)
- [...]: Guest has availability (intersect with host)

This addresses the review feedback about empty guest availability.
Tests cover:
- Returns null when booking not found
- Returns null when booking has no attendees
- Returns null when guest is not a Cal.com user
- Returns guest availability when guest IS a Cal.com user with slots
- Returns empty array when guest IS a Cal.com user with NO availability
- Excludes host emails from guest list
- Gracefully returns null on error (doesn't throw)

These tests verify the fix for the empty guest availability bug,
ensuring we distinguish between:
- null: Guest is not a Cal.com user
- []: Guest IS a Cal.com user with no availability
- [...]: Guest has availability
@JarvisInvestInsight JarvisInvestInsight requested a review from a team as a code owner February 3, 2026 19:56
@paragon-review
Copy link
Copy Markdown

paragon-review bot commented Feb 3, 2026

Paragon Review Unavailable

Hi @JarvisInvestInsight! To enable Paragon reviews on this repository, please register at https://home.polarity.cc

Once registered, connect your GitHub account and Paragon will automatically review your pull requests.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Feb 3, 2026
@github-actions github-actions bot added $200 bookings area: bookings, availability, timezones, double booking Medium priority Created by Linear-GitHub Sync ✨ feature New feature or request 💎 Bounty A bounty on Algora.io 🧹 Improvements Improvements to existing features. Mostly UX/UI labels Feb 3, 2026
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Feb 3, 2026

Graphite Automations

"Send notification to Community team when bounty PR opened" took an action on this PR • (02/03/26)

2 teammates were notified to this PR based on Keith Williams's automation.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/trpc/server/routers/viewer/slots/util.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/slots/util.ts:1303">
P2: Guest availability is intersected before fallback handling, but when fallback RR hosts are used the code recomputes aggregatedAvailability without reapplying that intersection. In fallback scenarios, reschedule slots can ignore the guest’s availability. Consider reapplying the guest availability intersection after the fallback recalculation (or moving the intersection to after fallback selection).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

let aggregatedAvailability = getAggregatedAvailability(allUsersAvailability, eventType.schedulingType);

// When rescheduling, check if the guest is a Cal.com user and intersect their availability
if (input.rescheduleUid) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Guest availability is intersected before fallback handling, but when fallback RR hosts are used the code recomputes aggregatedAvailability without reapplying that intersection. In fallback scenarios, reschedule slots can ignore the guest’s availability. Consider reapplying the guest availability intersection after the fallback recalculation (or moving the intersection to after fallback selection).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/slots/util.ts, line 1303:

<comment>Guest availability is intersected before fallback handling, but when fallback RR hosts are used the code recomputes aggregatedAvailability without reapplying that intersection. In fallback scenarios, reschedule slots can ignore the guest’s availability. Consider reapplying the guest availability intersection after the fallback recalculation (or moving the intersection to after fallback selection).</comment>

<file context>
@@ -1209,6 +1299,58 @@ export class AvailableSlotsService {
     let aggregatedAvailability = getAggregatedAvailability(allUsersAvailability, eventType.schedulingType);
 
+    // When rescheduling, check if the guest is a Cal.com user and intersect their availability
+    if (input.rescheduleUid) {
+      const guestAvailability = await this.getGuestAvailabilityForReschedule({
+        rescheduleUid: input.rescheduleUid,
</file context>
Fix with Cubic

@romitg2
Copy link
Copy Markdown
Member

romitg2 commented Feb 3, 2026

@JarvisInvestInsight Thank you for contribution! could you please add video demo?

@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Feb 11, 2026
@dhairyashiil dhairyashiil marked this pull request as draft February 17, 2026 10:11
@github-actions github-actions bot removed the Stale label Feb 18, 2026
@CharlesWong
Copy link
Copy Markdown

Implemented in #28371

/claim #27593

@sahitya-chandra
Copy link
Copy Markdown
Member

Thank you for your contribution. This PR is being closed because the linked issue is no longer exists in Cal.diy. blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking 💎 Bounty A bounty on Algora.io community Created by Linear-GitHub Sync ✨ feature New feature or request 🧹 Improvements Improvements to existing features. Mostly UX/UI Medium priority Created by Linear-GitHub Sync size/L $200

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-4531] Take into account guest's availability when rescheduling

4 participants