Skip to content

Comments

fix: Add guests via URL param even if field is hidden#23229

Merged
keithwillcode merged 3 commits intomainfrom
add-guests-if-hidden
Aug 21, 2025
Merged

fix: Add guests via URL param even if field is hidden#23229
keithwillcode merged 3 commits intomainfrom
add-guests-if-hidden

Conversation

@joeauyeung
Copy link
Contributor

What does this PR do?

Fixes a bug when the guests field is hidden, the URL param for guests wasn't being passed to the new booking

How should this be tested?

  • Hide the guests field for an event type
  • Go to the booking page but add the guests URL param
  • When the booking is created, the guests should be added

@joeauyeung joeauyeung requested a review from a team as a code owner August 20, 2025 18:36
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

  • Adds an optional boolean parameter seatsEnabled to getCalEventResponses’ input type and implementation.
  • Replaces guest inference gating from field.hidden to a check on seatsEnabled.
  • When processing fields, if name is "guests" and seatsEnabled is true, sets backwardCompatibleResponses["guests"] = [].
  • In handleNewBooking/getBookingData, passes seatsEnabled to getCalEventResponses based on Boolean(eventType.seatsPerTimeSlot).
  • No other logic changes; only getCalEventResponses’ public signature is updated.

Possibly related PRs

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-guests-if-hidden

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team August 20, 2025 18:37
@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Aug 20, 2025
@vercel
Copy link

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Aug 21, 2025 2:07am
cal-eu Ignored Ignored Aug 21, 2025 2:07am

@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working labels Aug 20, 2025
@graphite-app
Copy link

graphite-app bot commented Aug 20, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (08/20/25)

1 reviewer was added to this PR based on Keith Williams's automation.

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 (3)
packages/features/bookings/lib/getCalEventResponses.ts (2)

12-17: Signature change is fine; consider a default value for clarity

Optional: give seatsEnabled a default in the destructured params to avoid double-negation checks later and make intent explicit.

 export const getCalEventResponses = ({
   bookingFields,
   booking,
   responses,
-  seatsEnabled,
+  seatsEnabled = false,
 }: {
   // If the eventType has been deleted and a booking is Accepted later on, then bookingFields will be null and we can't know the label of fields. So, we should store the label as well in the DB
   // Also, it is no longer straightforward to identify if a field is system field or not
   bookingFields: z.infer<typeof eventTypeBookingFields> | EventType["bookingFields"] | null;
   booking?: Prisma.BookingGetPayload<{
@@
   }>;
   responses?: z.infer<typeof bookingResponsesDbSchema>;
-  seatsEnabled?: boolean;
+  seatsEnabled?: boolean;
 })

Also applies to: 36-37


66-68: Avoid hidden side effects on the input responses

This function mutates the incoming responses object (via backwardCompatibleResponses) so that callers later read the mutated guests. This coupling is brittle.

Offer: Return a normalizedResponses from this helper and consume that at the call site instead of relying on mutation. Example (outline):

TypeScript (inside this file):

// compute normalizedResponses locally without mutating the input
const normalizedResponses = { ...backwardCompatibleResponses };
// apply seats/guest normalization on normalizedResponses
return { userFieldsResponses: calEventUserFieldsResponses, responses: calEventResponses, normalizedResponses };

TypeScript (consumer at getBookingData.ts):

const { normalizedResponses } = getCalEventResponses(...);
const guests = normalizedResponses.guests ?? [];
packages/features/bookings/lib/handleNewBooking/getBookingData.ts (1)

63-69: Prefer explicit intent when deriving a boolean from seatsPerTimeSlot

Minor: If seatsPerTimeSlot is numeric, consider > 0 to express intent (enabled only when capacity > 0). The current !! coercion works but is less descriptive.

-      seatsEnabled: !!eventType.seatsPerTimeSlot,
+      seatsEnabled: (eventType.seatsPerTimeSlot ?? 0) > 0,

Note: If seatsPerTimeSlot can be non-numeric, ignore this suggestion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • 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 e309e72 and a465d3d.

📒 Files selected for processing (2)
  • packages/features/bookings/lib/getCalEventResponses.ts (3 hunks)
  • packages/features/bookings/lib/handleNewBooking/getBookingData.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.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/handleNewBooking/getBookingData.ts
  • packages/features/bookings/lib/getCalEventResponses.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/handleNewBooking/getBookingData.ts
  • packages/features/bookings/lib/getCalEventResponses.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Tests / Unit
  • GitHub Check: Type check / check-types
  • GitHub Check: Linters / lint
🔇 Additional comments (2)
packages/features/bookings/lib/getCalEventResponses.ts (1)

66-68: Guard “guests” default only when absent and use strict equality

We should only assign an empty array to responses.guests if seatsEnabled is true and no guests were provided. Also replace == and !! with strict checks, and document the intended “always ignore guests when seatsEnabled” policy if that’s desired.

• File: packages/features/bookings/lib/getCalEventResponses.ts
Lines: 66–68

-      if (field.name == "guests" && !!seatsEnabled) {
-        backwardCompatibleResponses[field.name] = [];
-      }
+      // Only default guests to [] when seats are enabled and no guests were provided
+      if (
+        field.name === "guests" &&
+        seatsEnabled &&
+        backwardCompatibleResponses[field.name] == null
+      ) {
+        backwardCompatibleResponses[field.name] = [];
+      }

• Confirm whether the product intends to always ignore any supplied “invitee guests” for group events when seatsEnabled is true. If so, add a brief comment here explaining that policy to avoid future regressions.

• We’ve found multiple call sites for getCalEventResponses (across TRPC handlers, webhooks, tasker, EE workflows, etc.). Please review those usages to ensure this change won’t introduce unintended gaps or relies on the old “clobber every time” behavior.

packages/features/bookings/lib/handleNewBooking/getBookingData.ts (1)

63-69: LGTM: seatsEnabled is correctly propagated

Passing seatsEnabled based on eventType.seatsPerTimeSlot ensures guest handling is now independent of the hidden flag, satisfying the PR objective.

getCalEventResponses({
bookingFields: eventType.bookingFields,
responses,
seatsEnabled: !!eventType.seatsPerTimeSlot,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only add this here since guests added via the URL param are only passed for new bookings.

@keithwillcode keithwillcode merged commit b9aee3b into main Aug 21, 2025
36 of 37 checks passed
@keithwillcode keithwillcode deleted the add-guests-if-hidden branch August 21, 2025 02:27
@github-actions
Copy link
Contributor

E2E results are ready!

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 core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants