diff --git a/packages/trpc/server/routers/viewer/organizations/list.handler.ts b/packages/trpc/server/routers/viewer/organizations/list.handler.ts index 883c627491..e737805cbe 100644 --- a/packages/trpc/server/routers/viewer/organizations/list.handler.ts +++ b/packages/trpc/server/routers/viewer/organizations/list.handler.ts @@ -11,7 +11,7 @@ type ListHandlerInput = { // This functionality is essentially the same as the teams/list.handler.ts but it's easier for SOC to have it in a separate file. export const listHandler = async ({ ctx }: ListHandlerInput) => { - const organizationId = ctx.user.organization?.id ?? ctx.user.profiles[0].organizationId; + const organizationId = ctx.user.organization?.id ?? ctx.user.profiles[0]?.organizationId; if (!organizationId) { throw new TRPCError({ code: "BAD_REQUEST", message: "You do not belong to an organization" }); }