diff --git a/packages/lib/server/service/insightsBooking.ts b/packages/lib/server/service/insightsBooking.ts index 08a3a7e74685de..4d74226b7e237b 100644 --- a/packages/lib/server/service/insightsBooking.ts +++ b/packages/lib/server/service/insightsBooking.ts @@ -261,14 +261,17 @@ export class InsightsBookingService { if (!this.options) { return NOTHING_CONDITION; } + + if (this.options.scope === "user") { + return Prisma.sql`("userId" = ${this.options.userId}) AND ("teamId" IS NULL)`; + } + const isOwnerOrAdmin = await this.isOrgOwnerOrAdmin(this.options.userId, this.options.orgId); if (!isOwnerOrAdmin) { return NOTHING_CONDITION; } - if (this.options.scope === "user") { - return Prisma.sql`("userId" = ${this.options.userId}) AND ("teamId" IS NULL)`; - } else if (this.options.scope === "org") { + if (this.options.scope === "org") { return await this.buildOrgAuthorizationCondition(this.options); } else if (this.options.scope === "team") { return await this.buildTeamAuthorizationCondition(this.options);