fix: managed event types inherit team hideBranding setting#23562
fix: managed event types inherit team hideBranding setting#23562
Conversation
- Add getParentTeamForBranding helper to query parent team data - Update shouldHideBrandingForEvent to use parent team when eventType.team is null - Ensures CTA 'create your own booking link with Cal' respects team branding settings - Follows existing pattern used by eventType.team?.id ?? eventType.parent?.teamId Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
WalkthroughExpanded the Prisma select in apps/web/lib/booking.ts to include Possibly related PRs
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ 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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
E2E results are ready! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/web/lib/booking.ts (2)
172-185: Replace Prismaincludewithselect(repo guideline)
We avoidincludein Prisma. Switch toselectand explicitly pick the fields you consume later (dataandattendee.*), keeping types intact.- seatAttendee = await prisma.bookingSeat.findUnique({ - where: { - referenceUid: seatReferenceUid, - }, - include: { - attendee: { - select: { - name: true, - email: true, - phoneNumber: true, - }, - }, - }, - }); + seatAttendee = await prisma.bookingSeat.findUnique({ + where: { referenceUid: seatReferenceUid }, + select: { + id: true, + bookingId: true, + attendeeId: true, + referenceUid: true, + data: true, + attendee: { + select: { + name: true, + email: true, + phoneNumber: true, + }, + }, + }, + });
96-111: Confirm platform-booking detection for managed (parent-team) events
If “platform booking” should also apply when the parent team is created by an OAuth client, consider readingcreatedByOAuthClientIdfrom the parent team and extending the check. If that’s not desired behavior, ignore.parent: { select: { - hideBranding: true, + hideBranding: true, }, }, createdByOAuthClientId: true, }, }, parent: { select: { teamId: true, - team: { + team: { select: { hideBranding: true, + createdByOAuthClientId: true, parent: { select: { hideBranding: true, }, }, }, }, }, },- const isPlatformBooking = eventType.users[0]?.isPlatformManaged || eventType.team?.createdByOAuthClientId; + const isPlatformBooking = + eventType.users[0]?.isPlatformManaged || + eventType.team?.createdByOAuthClientId || + eventType.parent?.team?.createdByOAuthClientId;Also applies to: 231-233
📜 Review details
Configuration used: Path: .coderabbit.yaml
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 ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (2)
apps/web/lib/booking.ts(1 hunks)apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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:
apps/web/lib/booking.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:
apps/web/lib/booking.tsapps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx
**/*.{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/lib/booking.tsapps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx
**/*.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/modules/bookings/views/bookings-single-view.getServerSideProps.tsx
🧠 Learnings (7)
📓 Common learnings
Learnt from: anglerfishlyy
PR: calcom/cal.com#0
File: :0-0
Timestamp: 2025-08-27T16:39:38.192Z
Learning: anglerfishlyy successfully implemented CAL-3076 email invitation feature for Cal.com team event-types in PR #23312. The feature allows inviting people via email directly from assignment flow, with automatic team invitation if email doesn't belong to existing team member. Implementation includes Host type modifications (userId?: number, email?: string, isPending?: boolean), CheckedTeamSelect component updates with CreatableSelect, TRPC schema validation with zod email validation, and integration with existing teamInvite system.
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.
Learnt from: supalarry
PR: calcom/cal.com#23217
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts:93-94
Timestamp: 2025-08-21T13:44:06.805Z
Learning: In apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, repository functions that use explicit Prisma select clauses (like getEventTypeWithSeats) are used for specific purposes and don't need to include all EventType fields like bookingRequiresAuthentication. These methods don't feed into the general OutputEventTypesService_2024_06_14 flow.
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
📚 Learning: 2025-08-21T13:44:06.805Z
Learnt from: supalarry
PR: calcom/cal.com#23217
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts:93-94
Timestamp: 2025-08-21T13:44:06.805Z
Learning: In apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, repository functions that use explicit Prisma select clauses (like getEventTypeWithSeats) are used for specific purposes and don't need to include all EventType fields like bookingRequiresAuthentication. These methods don't feed into the general OutputEventTypesService_2024_06_14 flow.
Applied to files:
apps/web/lib/booking.tsapps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Applied to files:
apps/web/lib/booking.ts
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Applied to files:
apps/web/lib/booking.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/lib/booking.tsapps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx
📚 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 BookingPaymentInitiatedDTO and other webhook DTOs in packages/features/webhooks/lib/dto/types.ts, the booking field is a restricted structure containing only specific fields (id, eventTypeId, userId) rather than the full database booking object, so there are no security or PII leakage concerns when passing the booking object to buildEventPayload.
Applied to files:
apps/web/lib/booking.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:
apps/web/lib/booking.ts
🔇 Additional comments (2)
apps/web/lib/booking.ts (1)
99-108: Branding inheritance data selection looks correctSelecting only
hideBrandingon the parent team (and its parent) keeps the payload minimal and adheres to our “select-only” Prisma guideline. This should enableshouldHideBrandingForEventto respect branding on managed/child event types.apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx (1)
241-242: Correctly prefer parent team for branding decisionsPassing
eventType.parent.team ?? eventType.teamtoshouldHideBrandingForEventaligns with the managed-event inheritance model and the new selection ingetEventTypesFromDB.Please confirm
shouldHideBrandingForEventaccepts a partial team shape (onlyhideBrandingandparent.hideBranding) when the parent team is used.
| : await shouldHideBrandingForEvent({ | ||
| eventTypeId: eventType.id, | ||
| team: eventType.team, | ||
| team: eventType?.parent?.team ? eventType.parent.team : eventType.team, |
There was a problem hiding this comment.
nit: eventType?.parent?.team ?? eventType.team
yarn.lock
Outdated
| jimp: ^0.16.1 | ||
| lingo.dev: ^0.111.1 | ||
| next-collect: ^0.2.1 | ||
| next-i18next: ^15.4.2 |
There was a problem hiding this comment.
Unrelated changes to yarn.lock. Let's revert these. Otherwise it is good
hariombalhara
left a comment
There was a problem hiding this comment.
to remove yarn.lock changes.
emrysal
left a comment
There was a problem hiding this comment.
Todo: optimise caching to make sure this isn't hit every time.
What does this PR do?
Fixes an issue where managed event types were not properly inheriting their team's
hideBrandingsetting, causing the "create your own booking link with Cal" CTA to appear on booking success pages even when the team had branding disabled.Problem: Managed event types (child event types) don't have direct team relationships - they inherit team context through their
parentId. The booking success page wasn't passing this parent team data to the branding functions, so managed event types couldn't inherit the team's branding settings.Solution:
getParentTeamForBrandinghelper function to query parent team data when neededshouldHideBrandingForEventcall to use parent team data wheneventType.teamis null buteventType.parent?.teamIdexistseventType.team?.id ?? eventType.parent?.teamIdLink to Devin run: https://app.devin.ai/sessions/558321e957d540b1bfc5c4eaf04a0758
Requested by: @joeauyeung
How should this be tested?
Test Steps:
Expected behavior:
hideBranding: true, the CTA should be hidden on booking success pagesMandatory Tasks (DO NOT REMOVE)
Human Review Checklist
Critical items to verify:
hideBrandingvaluesChecklist