fix: Add guests via URL param even if field is hidden#23229
fix: Add guests via URL param even if field is hidden#23229keithwillcode merged 3 commits intomainfrom
Conversation
Walkthrough
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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. |
There was a problem hiding this comment.
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 clarityOptional: 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 responsesThis 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 seatsPerTimeSlotMinor: 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.
📒 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 useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/features/bookings/lib/handleNewBooking/getBookingData.tspackages/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.tspackages/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 equalityWe 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 propagatedPassing 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, |
There was a problem hiding this comment.
We only add this here since guests added via the URL param are only passed for new bookings.
E2E results are ready! |
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?
guestsURL param