From 286ee6b1bd6d46183691b2c5410cd8733805c45d Mon Sep 17 00:00:00 2001 From: Amit Sharma <74371312+Amit91848@users.noreply.github.com> Date: Fri, 19 Sep 2025 16:02:24 +0530 Subject: [PATCH] fix: disable intercom while being impersonated (#23935) --- packages/features/ee/support/lib/intercom/provider.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/features/ee/support/lib/intercom/provider.tsx b/packages/features/ee/support/lib/intercom/provider.tsx index 45fbda0b05..3a6ff6f2b2 100644 --- a/packages/features/ee/support/lib/intercom/provider.tsx +++ b/packages/features/ee/support/lib/intercom/provider.tsx @@ -1,5 +1,6 @@ "use client"; +import { useSession } from "next-auth/react"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useEffect, type FC } from "react"; import { IntercomProvider } from "react-use-intercom"; @@ -31,6 +32,9 @@ const Provider: FC<{ children: React.ReactNode }> = ({ children }) => { const searchParams = useSearchParams(); const pathname = usePathname(); const router = useRouter(); + const { data: session } = useSession(); + + const isBeingImpersonated = !!session?.user?.impersonatedBy?.id; const shouldOpenSupport = pathname === "/event-types" && (searchParams?.has("openPlain") || searchParams?.has("openSupport")); @@ -65,7 +69,7 @@ const Provider: FC<{ children: React.ReactNode }> = ({ children }) => { const isOnboardingPage = pathname?.startsWith("/getting-started"); const isCalVideoPage = pathname?.startsWith("/video/"); - if (isOnboardingPage || isCalVideoPage) { + if (isOnboardingPage || isCalVideoPage || isBeingImpersonated) { return <>{children}; }