From dc44825ce522d825de10dc6b0ef47bedbae3e1fb Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Thu, 4 Dec 2025 14:18:45 -0500 Subject: [PATCH] fix: prevent overwriting existing event type values with undefined (#25624) When updating an event type, fields like autoTranslateDescriptionEnabled and disableGuests were being overwritten with false/default values even when they weren't explicitly provided in the update request. Changes: - autoTranslateDescriptionEnabled: Only set when explicitly provided (not undefined) to avoid overwriting existing true values with false - disableGuests: Only set when bookingFields is explicitly provided, since it's derived from the guests field in bookingFields Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../routers/viewer/eventTypes/heavy/update.handler.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts b/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts index 13750114b7..7e926f9b6e 100644 --- a/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts +++ b/packages/trpc/server/routers/viewer/eventTypes/heavy/update.handler.ts @@ -232,7 +232,10 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => { const data: Prisma.EventTypeUpdateInput = { ...rest, // autoTranslate feature is allowed for org users only - autoTranslateDescriptionEnabled: !!(ctx.user.organizationId && autoTranslateDescriptionEnabled), + // Only set if explicitly provided to avoid overwriting existing value with false + ...(autoTranslateDescriptionEnabled !== undefined && { + autoTranslateDescriptionEnabled: Boolean(ctx.user.organizationId && autoTranslateDescriptionEnabled), + }), description: newDescription, title: newTitle, bookingFields, @@ -242,7 +245,10 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => { rest.rrSegmentQueryValue === null ? Prisma.DbNull : (rest.rrSegmentQueryValue as Prisma.InputJsonValue), metadata: rest.metadata === null ? Prisma.DbNull : (rest.metadata as Prisma.InputJsonObject), eventTypeColor: eventTypeColor === null ? Prisma.DbNull : (eventTypeColor as Prisma.InputJsonObject), - disableGuests: guestsField?.hidden ?? false, + // Only set disableGuests if bookingFields is explicitly provided to avoid overwriting existing value + ...(bookingFields !== undefined && { + disableGuests: guestsField?.hidden ?? false, + }), seatsPerTimeSlot, maxLeadThreshold: isLoadBalancingDisabled ? null : rest.maxLeadThreshold, };