diff --git a/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx b/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx index 93dccd0da0f751..ca2678c36e5c8b 100644 --- a/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx +++ b/apps/web/modules/bookings/views/bookings-single-view.getServerSideProps.tsx @@ -163,10 +163,24 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { }); const userId = session?.user?.id; - const isLoggedInUserHost = - userId && - (eventType.users.some((user) => user.id === userId) || - eventType.hosts.some(({ user }) => user.id === userId)); + + const checkIfUserIsHost = (userId?: number | null) => { + if (!userId) return false; + + return ( + bookingInfo?.user?.id === userId || + eventType.users.some( + (user) => + user.id === userId && bookingInfo.attendees.some((attendee) => attendee.email === user.email) + ) || + eventType.hosts.some( + ({ user }) => + user.id === userId && bookingInfo.attendees.some((attendee) => attendee.email === user.email) + ) + ); + }; + + const isLoggedInUserHost = checkIfUserIsHost(userId); if (!isLoggedInUserHost) { // Removing hidden fields from responses