From 72ff29fdf145398eba3b4977fb3530e7b33e7f33 Mon Sep 17 00:00:00 2001 From: The Mavik <179817126+themavik@users.noreply.github.com> Date: Mon, 9 Feb 2026 23:10:24 +0530 Subject: [PATCH] fix: only show upgrade prompt to org owners, not regular users (#815) Root cause: The layout's billing check wraps ALL users in UpgradeGuard when the subscription is expired, redirecting everyone to the upgrade page. Non-owner users cannot perform billing actions, so showing them the upgrade page is confusing. Fix: Hoist the membership variable from the auth block and check the user's role at the billing guard. Only org owners are redirected to the upgrade page. Non-owners see a message asking them to contact their organization owner. --- packages/web/src/app/[domain]/layout.tsx | 35 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/web/src/app/[domain]/layout.tsx b/packages/web/src/app/[domain]/layout.tsx index f2085757a..2879361b6 100644 --- a/packages/web/src/app/[domain]/layout.tsx +++ b/packages/web/src/app/[domain]/layout.tsx @@ -63,9 +63,15 @@ export default async function Layout(props: LayoutProps) { return status; })(); + // Hoist membership so it's available for the billing owner check below (#815) + let membership: Awaited>> = null; + // If the user is authenticated, we must check if they're a member of the org if (session) { - const membership = await prisma.userToOrg.findUnique({ + membership = await prisma.userToOrg.findUnique({ where: { orgId_userId: { orgId: org.id, @@ -171,11 +177,28 @@ export default async function Layout(props: LayoutProps) { (subscription.status !== "active" && subscription.status !== "trialing") ) ) { - return ( - - {children} - - ) + // Only redirect org owners to the upgrade page. + // Non-owners see a message to contact their org owner (#815). + if (membership?.role === 'OWNER') { + return ( + + {children} + + ) + } else { + return ( +
+ +
+

Subscription Expired

+

+ Your organization's subscription has expired or is inactive. + Please contact your organization owner to renew the subscription. +

+
+
+ ) + } } }