@@ -352,6 +352,13 @@ async function handler(req: NextRequest) {
352352 title : booking . title || booking . eventType ?. title || "" ,
353353 } ;
354354
355+ const customReplyTo = reminder . booking ?. eventType ?. customReplyToEmail ;
356+ const fallbackReplyTo =
357+ reminder . booking ?. userPrimaryEmail ?? reminder . booking ?. user ?. email ;
358+ const replyTo = reminder . booking ?. eventType ?. hideOrganizerEmail
359+ ? customReplyTo
360+ : customReplyTo ?? fallbackReplyTo ;
361+
355362 const mailData = {
356363 subject : emailContent . emailSubject ,
357364 to : Array . isArray ( sendTo ) ? sendTo : [ sendTo ] ,
@@ -367,13 +374,8 @@ async function handler(req: NextRequest) {
367374 ]
368375 : undefined ,
369376 sender : reminder . workflowStep . sender ,
370- ...( ! reminder . booking ?. eventType ?. hideOrganizerEmail && {
371- replyTo :
372- reminder . booking ?. eventType ?. customReplyToEmail ??
373- reminder . booking ?. userPrimaryEmail ??
374- reminder . booking . user ?. email ,
375- } ) ,
376- } ;
377+ ...( replyTo ? { replyTo } : { } ) ,
378+ } ;
377379
378380 if ( isSendgridEnabled ) {
379381 sendEmailPromises . push (
@@ -448,18 +450,19 @@ async function handler(req: NextRequest) {
448450 } ) ;
449451 if ( emailContent . emailSubject . length > 0 && ! emailBodyEmpty && sendTo ) {
450452 const batchId = isSendgridEnabled ? await getBatchId ( ) : undefined ;
453+ const customReplyTo = reminder . booking ?. eventType ?. customReplyToEmail ;
454+ const fallbackReplyTo =
455+ reminder . booking ?. userPrimaryEmail || reminder . booking ?. user ?. email ;
456+ const replyTo = reminder . booking ?. eventType ?. hideOrganizerEmail
457+ ? customReplyTo
458+ : customReplyTo || fallbackReplyTo ;
451459
452460 const mailData = {
453461 subject : emailContent . emailSubject ,
454462 to : [ sendTo ] ,
455463 html : emailContent . emailBody ,
456464 sender : reminder . workflowStep ?. sender ,
457- ...( ! reminder . booking ?. eventType ?. hideOrganizerEmail && {
458- replyTo :
459- reminder . booking ?. eventType ?. customReplyToEmail ||
460- reminder . booking ?. userPrimaryEmail ||
461- reminder . booking . user ?. email ,
462- } ) ,
465+ ...( replyTo ? { replyTo } : { } ) ,
463466 } ;
464467 if ( isSendgridEnabled ) {
465468 sendEmailPromises . push (
0 commit comments