Skip to content

Comments

fix: event host unable to cancel event when Disable Cancelling is enabled.#24021

Open
GurneeshBudhiraja wants to merge 16 commits intocalcom:mainfrom
GurneeshBudhiraja:bug/host-unable-to-cancel-event
Open

fix: event host unable to cancel event when Disable Cancelling is enabled.#24021
GurneeshBudhiraja wants to merge 16 commits intocalcom:mainfrom
GurneeshBudhiraja:bug/host-unable-to-cancel-event

Conversation

@GurneeshBudhiraja
Copy link

@GurneeshBudhiraja GurneeshBudhiraja commented Sep 24, 2025

What does this PR do?

The PR fixes the bug that was preventing the hosts to cancel their own events when Disable Cancelling is enabled.

Updates since last revision

Addressed review feedback and fixed additional issues:

  1. Fixed cancel action logic (bookingActions.ts): The host bypass now also checks isCancelled and isRejected states to prevent hosts from attempting to cancel already cancelled/rejected bookings.

  2. Fixed missing isHost in dropdown (BookingActionsDropdown.tsx): The isHost flag was computed but not included in the actionContext object, causing the host bypass to not work in the dropdown component. This was the root cause of the fix not working properly.

  3. Added test cases: Two new tests verify that hosts cannot cancel already cancelled or rejected bookings.

Visual Demo (For contributors especially)

Video Demo (if applicable):

The below video demo shows the updated functionality for both the host account(on the right) and the attendee account(on the left).
Loom Video Link

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

The hosts should be able to cancel the event even when Disable Cancelling is enabled. On the other hand, for somebody viewing the event other than the host, they would not be able to cancel it.

Test scenarios:

  1. As a host with Disable Cancelling enabled, verify you CAN cancel an upcoming booking
  2. As an attendee with Disable Cancelling enabled, verify you CANNOT cancel the booking
  3. Verify that hosts cannot cancel already cancelled or rejected bookings (edge case)

Checklist for human review

  • Verify isHost is correctly computed in both BookingListItem.tsx (line 189-192) and BookingActionsDropdown.tsx (line 201)
  • Verify the cancel action logic in bookingActions.ts (line 267) correctly handles the host bypass with cancelled/rejected checks

Link to Devin run: https://app.devin.ai/sessions/1f26c48a6898417188d7d856880e3f8b
Requested by: unknown ()

@CLAassistant
Copy link

CLAassistant commented Sep 24, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

Adds host detection in BookingListItem and passes an optional isHost flag through BookingActionContext. BookingActionContext’s attendee item shape is expanded (id, noShow, phoneNumber). bookingActions now permits cancel when isHost is true by short-circuiting cancel-disabled checks; a minor variable rename in getActionLabel was made. Server-side cancellation logic (handleCancelBooking) is updated to compute isCancellationUserHost earlier and allow host-initiated cancellations for event types that disable guest cancellations. Tests were added to assert host-can-cancel and non-host-cannot for disabled-cancellation events; two duplicate test pairs were introduced.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning There are out-of-scope items: the BookingActionContext attendee type was expanded with id/noShow/phoneNumber (a public/type-level change not required by the bug description) and handleCancelBooking.test.ts contains duplicated test cases; these changes are unrelated to the core objective of permitting hosts to cancel and should be justified or removed. Revert or document the public/type expansions in BookingActionContext if they are not strictly necessary for this bugfix, remove the duplicated tests from handleCancelBooking.test.ts, and if additional type/API changes are required, split them into a focused follow-up PR so this change remains minimal and reviewable.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change — allowing event hosts to cancel events when "Disable Cancelling" is enabled — and directly maps to the changeset and referenced issues, so it is clear to reviewers scanning PR history.
Linked Issues Check ✅ Passed The changes implement the primary objective from the linked issues by allowing hosts to cancel despite "Disable Cancelling" being set: the frontend adds an isHost flag and bypasses the cancel-disabled UI, the server-side handleCancelBooking now permits host-initiated cancellations while blocking non-hosts, and tests asserting both allowed and blocked cases were added, addressing the user stories in [#24017] and [CAL-6452].
Description Check ✅ Passed The PR description describes the bug being fixed, cites the linked issues (#24017 and CAL-6452), notes added tests and a demo video, and matches the implemented changes in both UI and backend, so it is related to the changeset.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 786b702 and 35d6eb1.

📒 Files selected for processing (2)
  • packages/features/bookings/lib/handleCancelBooking.ts (2 hunks)
  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
  • packages/features/bookings/lib/handleCancelBooking.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: In the Cal.com codebase, the forceRescheduleForCancelledBooking flag historically affects both CANCELLED and REJECTED booking statuses, despite its name suggesting it should only affect cancelled bookings. This behavior existed before PR #23736 and was preserved during the refactoring.
📚 Learning: 2025-09-12T11:23:34.158Z
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: The test file packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.test.ts explicitly documents on line 236 that the current behavior of forceRescheduleForCancelledBooking affecting both CANCELLED and REJECTED bookings is known to be incorrect, but is preserved as "Current Behavior" for backward compatibility. The test comment states the expected behavior should be that REJECTED bookings redirect to booking details even when forceRescheduleForCancelledBooking=true.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
📚 Learning: 2025-08-27T13:32:46.887Z
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts
📚 Learning: 2025-08-21T13:55:23.470Z
Learnt from: alishaz-polymath
PR: calcom/cal.com#23247
File: packages/features/webhooks/lib/service/FormWebhookService.ts:0-0
Timestamp: 2025-08-21T13:55:23.470Z
Learning: In the new webhook architecture for Cal.com, schedulePayload is considered legacy code that doesn't fit the clean architecture. The new architecture keeps webhook scheduling logic within the Service layer, specifically through a new method WebhookService.scheduleDelayedWebhooks, rather than using the old centralized schedulePayload helper.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
📚 Learning: 2025-08-21T12:28:42.018Z
Learnt from: alishaz-polymath
PR: calcom/cal.com#23247
File: packages/features/webhooks/lib/factory/WebhookPayloadFactory.ts:274-282
Timestamp: 2025-08-21T12:28:42.018Z
Learning: In webhook DTOs in packages/features/webhooks/lib/dto/types.ts, the booking fields are restricted structures containing only specific fields (id, eventTypeId, userId, and sometimes additional fields like startTime or smsReminderNumber) rather than full database booking objects, so there are no security or PII leakage concerns when using these booking objects in webhook payloads.

Applied to files:

  • packages/features/bookings/lib/handleCancelBooking.ts
🧬 Code graph analysis (1)
packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts (1)
apps/web/test/utils/bookingScenario/bookingScenario.ts (7)
  • getBooker (2223-2237)
  • getOrganizer (1520-1579)
  • TestData (1239-1511)
  • getGoogleCalendarCredential (1192-1200)
  • getDate (1093-1140)
  • createBookingScenario (978-1009)
  • getScenarioData (1581-1667)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (5)
packages/features/bookings/lib/handleCancelBooking.ts (2)

8-8: LGTM - Import addition is correct.

The EventManager import is properly added and follows the existing import pattern.


110-119: LGTM - Host-based cancellation logic is well-implemented.

The implementation correctly:

  • Precomputes host status early in the function for clarity
  • Uses proper equality checks (== for userId comparison handles null/undefined gracefully)
  • Applies the host override logic only when cancellation is disabled
  • Provides a clear error message for non-host users

The logic aligns perfectly with the PR objectives to allow hosts to cancel even when "Disable Cancelling" is enabled.

packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts (3)

946-1008: Test covers the host cancellation scenario correctly.

The test properly verifies that hosts can cancel bookings even when disableCancelling is enabled. The test setup is comprehensive with appropriate event type configuration and booking data.


1010-1072: Test correctly validates non-host cancellation prevention.

This test ensures that non-host users are blocked from cancelling when disableCancelling is enabled. The error message assertion matches the implementation.


946-1072: Incorrect — no duplicate tests found

The two tests are distinct and appear once each: line 946 ("Should allow host to cancel booking even when cancellation is disabled") and line 1010 ("Should prevent non-host from canceling when cancellation is disabled").

Likely an incorrect or invalid review comment.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Sep 24, 2025
@graphite-app graphite-app bot requested a review from a team September 24, 2025 02:46
@github-actions github-actions bot added the bookings area: bookings, availability, timezones, double booking label Sep 24, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "fix #24017 - Event host unable to cancel event when `Disable Cancelling` is enabled.". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@vercel
Copy link

vercel bot commented Sep 24, 2025

@GurneeshBudhiraja is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the 🐛 bug Something isn't working label Sep 24, 2025
@GurneeshBudhiraja GurneeshBudhiraja changed the title Fixes #24017 - Event host unable to cancel event when Disable Cancelling is enabled. fix #24017 - Event host unable to cancel event when Disable Cancelling is enabled. Sep 24, 2025
@GurneeshBudhiraja GurneeshBudhiraja changed the title fix #24017 - Event host unable to cancel event when Disable Cancelling is enabled. fix: #24017 Event host unable to cancel event when Disable Cancelling is enabled. Sep 24, 2025
@GurneeshBudhiraja GurneeshBudhiraja changed the title fix: #24017 Event host unable to cancel event when Disable Cancelling is enabled. fix: event host unable to cancel event when Disable Cancelling is enabled. Sep 24, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/components/booking/bookingActions.ts (1)

26-33: Consider making attendee list type more explicit.

The inline type definition for attendeeList could be extracted into a named type for better maintainability and reusability.

+export type BookingAttendee = {
+  name: string;
+  email: string;
+  id: number;
+  noShow: boolean;
+  phoneNumber: string | null;
+};
+
 export interface BookingActionContext {
   booking: BookingItemProps;
   // ... other fields ...
   isHost?: boolean;
-  attendeeList: Array<{
-    name: string;
-    email: string;
-    id: number;
-    noShow: boolean;
-    phoneNumber: string | null;
-  }>;
+  attendeeList: Array<BookingAttendee>;
   getSeatReferenceUid: () => string | undefined;
   t: (key: string) => string;
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bcc433b and 786b702.

📒 Files selected for processing (3)
  • apps/web/components/booking/BookingListItem.tsx (2 hunks)
  • apps/web/components/booking/bookingActions.test.ts (2 hunks)
  • apps/web/components/booking/bookingActions.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • apps/web/components/booking/BookingListItem.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/components/booking/BookingListItem.tsx
  • apps/web/components/booking/bookingActions.test.ts
  • apps/web/components/booking/bookingActions.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/components/booking/BookingListItem.tsx
  • apps/web/components/booking/bookingActions.test.ts
  • apps/web/components/booking/bookingActions.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/web/components/booking/bookingActions.test.ts
  • apps/web/components/booking/bookingActions.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: In the Cal.com codebase, the forceRescheduleForCancelledBooking flag historically affects both CANCELLED and REJECTED booking statuses, despite its name suggesting it should only affect cancelled bookings. This behavior existed before PR #23736 and was preserved during the refactoring.
📚 Learning: 2025-09-12T11:23:34.158Z
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: The test file packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.test.ts explicitly documents on line 236 that the current behavior of forceRescheduleForCancelledBooking affecting both CANCELLED and REJECTED bookings is known to be incorrect, but is preserved as "Current Behavior" for backward compatibility. The test comment states the expected behavior should be that REJECTED bookings redirect to booking details even when forceRescheduleForCancelledBooking=true.

Applied to files:

  • apps/web/components/booking/bookingActions.test.ts
📚 Learning: 2025-08-27T13:32:46.887Z
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.

Applied to files:

  • apps/web/components/booking/bookingActions.test.ts
🧬 Code graph analysis (1)
apps/web/components/booking/bookingActions.test.ts (1)
apps/web/components/booking/bookingActions.ts (1)
  • isActionDisabled (207-234)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (7)
apps/web/components/booking/bookingActions.test.ts (2)

506-514: LGTM! Test validates the fix for issue #24017.

The test correctly verifies that hosts can cancel bookings even when the "Disable Cancelling" feature is enabled, which directly addresses the bug fix objective.


47-57: LGTM! Type safety improvement.

Removing the type assertion improves type safety without changing functionality.

apps/web/components/booking/bookingActions.ts (2)

207-224: Excellent implementation of the host override logic.

The implementation correctly grants hosts the ability to cancel events regardless of the isDisabledCancelling setting, fixing the reported issue. The early return pattern is clean and efficient.


237-237: Good practice: Prefixing unused variables.

Using the underscore prefix for _booking correctly indicates it's intentionally unused while avoiding linter warnings.

apps/web/components/booking/BookingListItem.tsx (3)

192-196: Host detection logic correctly implemented.

The host detection properly checks both the booking's user ID and the logged-in user's ID to determine host status. The null checks ensure safety.


137-145: Attendee list mapping aligns with updated type definition.

The attendee list correctly includes all required fields (id, noShow, phoneNumber) as defined in the BookingActionContext interface.


239-266: Context object properly includes isHost flag.

The BookingActionContext is correctly constructed with the new isHost property, enabling the host-specific cancellation logic in the action handlers.

Copy link
Contributor

@Devanshusharma2005 Devanshusharma2005 left a comment

Choose a reason for hiding this comment

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

Lets add loom to show the changes.

bookingId: 1,
noShow: false,
} as any,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

why this ?

Copy link
Author

@GurneeshBudhiraja GurneeshBudhiraja Sep 24, 2025

Choose a reason for hiding this comment

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

any was giving the type issue at the time of commit.

@GurneeshBudhiraja
Copy link
Author

Lets add loom to show the changes.

I have added the Loom link in the PR description

@GurneeshBudhiraja GurneeshBudhiraja requested a review from a team as a code owner September 24, 2025 06:47
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 24, 2025
@github-actions
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Oct 14, 2025
Copy link
Contributor

@pallava-joshi pallava-joshi left a comment

Choose a reason for hiding this comment

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

looks good, can you please resolve the merge conflicts here.

@pallava-joshi
Copy link
Contributor

I'm marking this draft until then. feel free to tag me here; happy to help :)

@pallava-joshi pallava-joshi marked this pull request as draft November 25, 2025 13:36
@github-actions
Copy link
Contributor

Devin AI is resolving merge conflicts

This PR has merge conflicts with the main branch. A Devin session has been created to automatically resolve them.

View Devin Session

Devin will:

  1. Merge the latest main into this branch
  2. Resolve any conflicts intelligently
  3. Run lint/type checks to ensure validity
  4. Push the resolved changes

If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Devin AI is resolving merge conflicts

This PR has merge conflicts with the main branch. A Devin session has been created to automatically resolve them.

View Devin Session

Devin will:

  1. Merge the latest main into this branch
  2. Resolve any conflicts intelligently
  3. Run lint/type checks to ensure validity
  4. Push the resolved changes

If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself.

@romitg2
Copy link
Member

romitg2 commented Feb 4, 2026

@cubic-dev-ai

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 4, 2026

@cubic-dev-ai

@romitg2 I have started the AI code review. It will take a few minutes to complete.

Copy link
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.

3 issues found across 5 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="apps/web/components/booking/actions/bookingActions.ts">

<violation number="1" location="apps/web/components/booking/actions/bookingActions.ts:267">
P2: Host override skips cancelled/rejected checks, enabling cancel for already cancelled/rejected bookings.</violation>

<violation number="2" location="apps/web/components/booking/actions/bookingActions.ts:267">
P2: `isHost` is never provided by the action context builder, so the new cancel override always sees `undefined` and the fix has no effect.</violation>
</file>

<file name="packages/features/bookings/lib/handleCancelBooking.ts">

<violation number="1" location="packages/features/bookings/lib/handleCancelBooking.ts:222">
P3: Duplicated host-authorization logic triggers the org-admin DB lookup twice for seated events, adding redundant query work and risking drift between the two authorization checks. Consider reusing the earlier computed result (e.g., cache the org-admin check or reuse isCancellationUserHost) instead of repeating the same call.</violation>
</file>

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

isWithinMinimumNotice
);
case "cancel":
if (isHost && !isBookingInPast) return false;
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: isHost is never provided by the action context builder, so the new cancel override always sees undefined and the fix has no effect.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/components/booking/actions/bookingActions.ts, line 267:

<comment>`isHost` is never provided by the action context builder, so the new cancel override always sees `undefined` and the fix has no effect.</comment>

<file context>
@@ -263,6 +264,7 @@ export function isActionDisabled(actionId: string, context: BookingActionContext
         isWithinMinimumNotice
       );
     case "cancel":
+      if (isHost && !isBookingInPast) return false;
       return isDisabledCancelling || isBookingInPast || isCancelled || isRejected;
     case "view_recordings":
</file context>
Fix with Cubic

isCancellationUserHost = true;
}
else if (
await PrismaOrgMembershipRepository.isLoggedInUserOrgAdminOfBookingHost(
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P3: Duplicated host-authorization logic triggers the org-admin DB lookup twice for seated events, adding redundant query work and risking drift between the two authorization checks. Consider reusing the earlier computed result (e.g., cache the org-admin check or reuse isCancellationUserHost) instead of repeating the same call.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/features/bookings/lib/handleCancelBooking.ts, line 222:

<comment>Duplicated host-authorization logic triggers the org-admin DB lookup twice for seated events, adding redundant query work and risking drift between the two authorization checks. Consider reusing the earlier computed result (e.g., cache the org-admin check or reuse isCancellationUserHost) instead of repeating the same call.</comment>

<file context>
@@ -207,16 +207,35 @@ async function handler(input: CancelBookingInput, dependencies?: Dependencies) {
+      isCancellationUserHost = true;
+    }
+    else if (
+      await PrismaOrgMembershipRepository.isLoggedInUserOrgAdminOfBookingHost(
+        userId,
+        bookingToDelete.userId
</file context>
Fix with Cubic

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Devin AI is completing this stale PR

This PR by @GurneeshBudhiraja has been marked as stale. A Devin session has been created to complete the remaining work.

View Devin Session


Devin will review the PR, address any feedback, and push updates to complete this PR.

Address review feedback from cubic-dev-ai:
- Add checks for isCancelled and isRejected in the isHost bypass
- Add tests to verify hosts cannot cancel already cancelled or rejected bookings

Co-authored-by: GurneeshBudhiraja <gurneeshbudhiraja@gmail.com>
Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Contributor

Summary of Changes

I've completed this PR by addressing the review feedback from @cubic-dev-ai.

Changes Made

Fixed the isHost bypass to also check for cancelled/rejected bookings (commit 9348f9c)

The original implementation allowed hosts to cancel bookings even when "Disable Cancelling" was enabled, but it didn't check if the booking was already cancelled or rejected. This could have allowed hosts to attempt cancelling already cancelled/rejected bookings.

Code change in bookingActions.ts:

case "cancel":
-  if (isHost && !isBookingInPast) return false;
+  if (isHost && !isBookingInPast && !isCancelled && !isRejected) return false;
   return isDisabledCancelling || isBookingInPast || isCancelled || isRejected;

Added tests to verify:

  • Hosts cannot cancel already cancelled bookings
  • Hosts cannot cancel rejected bookings

Verification

Note on Other Review Comments

  • Comment WordPress plugin #26 about isHost not being provided: This is incorrect - isHost IS being passed in BookingListItem.tsx (lines 189-192 compute it, line 243 adds it to the context)
  • Comment Star count #27 about duplicated org-admin DB lookup: This is a P3 optimization suggestion that could be addressed in a follow-up PR

Completed by Devin AI on behalf of @GurneeshBudhiraja
Devin Session

Copy link
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 (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.


<file name="apps/web/components/booking/actions/bookingActions.ts">

<violation number="1" location="apps/web/components/booking/actions/bookingActions.ts:267">
P2: The updated cancel bypass relies on `isHost`, but the action context never supplies `isHost`, so hosts still can’t bypass `disableCancelling` as intended.</violation>
</file>

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

The isHost flag was computed but not included in the actionContext,
causing the host bypass for disableCancelling to not work in the
dropdown component.

Co-authored-by: GurneeshBudhiraja <gurneeshbudhiraja@gmail.com>
Co-Authored-By: unknown <>
@romitg2
Copy link
Member

romitg2 commented Feb 5, 2026

@cubic-dev-ai

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Feb 5, 2026

@cubic-dev-ai

@romitg2 I have started the AI code review. It will take a few minutes to complete.

Copy link
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 6 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="apps/web/components/booking/BookingListItem.tsx">

<violation number="1" location="apps/web/components/booking/BookingListItem.tsx:189">
P2: isHost is computed using only userId equality, which doesn’t account for team host assignments that depend on attendee email. This diverges from server-side host determination and can block legitimate hosts from canceling/rescheduling when Disable Cancelling is enabled.</violation>
</file>

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

const isAttendee = !!userSeat;

// Checks if the logged in user is the host of the booking
const isHost =
Copy link
Contributor

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

Choose a reason for hiding this comment

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

P2: isHost is computed using only userId equality, which doesn’t account for team host assignments that depend on attendee email. This diverges from server-side host determination and can block legitimate hosts from canceling/rescheduling when Disable Cancelling is enabled.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/components/booking/BookingListItem.tsx, line 189:

<comment>isHost is computed using only userId equality, which doesn’t account for team host assignments that depend on attendee email. This diverges from server-side host determination and can block legitimate hosts from canceling/rescheduling when Disable Cancelling is enabled.</comment>

<file context>
@@ -185,6 +185,12 @@ function BookingListItem(booking: BookingItemProps) {
   const isAttendee = !!userSeat;
 
+  // Checks if the logged in user is the host of the booking
+  const isHost =
+    booking.user?.id != null &&
+    booking.loggedInUser.userId != null &&
</file context>
Fix with Cubic

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 🐛 bug Something isn't working community Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When the cancelation is disable for the guest in the event definition, the host is also unable to cancel the event from the reservation dashboard

8 participants