diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts index e0b98b2ca0..23d10c8dbe 100644 --- a/packages/app-store/googlecalendar/lib/CalendarService.ts +++ b/packages/app-store/googlecalendar/lib/CalendarService.ts @@ -97,10 +97,9 @@ export default class GoogleCalendarService implements Calendar { responseStatus: "accepted", })) || []; return new Promise(async (resolve, reject) => { - const [mainHostDestinationCalendar] = - calEventRaw?.destinationCalendar && calEventRaw?.destinationCalendar.length > 0 - ? calEventRaw.destinationCalendar - : []; + const selectedHostDestinationCalendar = calEventRaw.destinationCalendar?.find( + (cal) => cal.credentialId === credentialId + ); const myGoogleAuth = await this.auth.getToken(); const payload: calendar_v3.Schema$Event = { summary: calEventRaw.title, @@ -119,8 +118,8 @@ export default class GoogleCalendarService implements Calendar { id: String(calEventRaw.organizer.id), responseStatus: "accepted", organizer: true, - email: mainHostDestinationCalendar?.externalId - ? mainHostDestinationCalendar.externalId + email: selectedHostDestinationCalendar?.externalId + ? selectedHostDestinationCalendar.externalId : calEventRaw.organizer.email, }, ...eventAttendees,