From babeb1f31d5e484757b8a9f761982eeeccf76060 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Tue, 26 Aug 2025 00:12:30 +0530 Subject: [PATCH] fix get booking issue (#23344) --- packages/trpc/server/routers/viewer/bookings/get.handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/trpc/server/routers/viewer/bookings/get.handler.ts b/packages/trpc/server/routers/viewer/bookings/get.handler.ts index 34c5bbeb32..8974e1183a 100644 --- a/packages/trpc/server/routers/viewer/bookings/get.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/get.handler.ts @@ -151,10 +151,12 @@ export async function getBookings({ userIdsWhereUserIsAdminOrOwner.includes(userId) ); + const isCurrentUser = filters.userIds.length === 1 && user.id === filters.userIds[0]; + // Scope depends on `user.orgId`: // - Throw an error if trying to filter by usersIds that are not within your ORG // - Throw an error if trying to filter by usersIds that are not within your TEAM - if (!areUserIdsWithinUserOrgOrTeam) { + if (!areUserIdsWithinUserOrgOrTeam && !isCurrentUser) { throw new TRPCError({ code: "FORBIDDEN", message: "You do not have permissions to fetch bookings for specified userIds",