diff --git a/apps/web/components/apps/MultiDisconnectIntegration.tsx b/apps/web/components/apps/MultiDisconnectIntegration.tsx index 3b3c54327e..5ecbecbdcc 100644 --- a/apps/web/components/apps/MultiDisconnectIntegration.tsx +++ b/apps/web/components/apps/MultiDisconnectIntegration.tsx @@ -39,7 +39,7 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) { const mutation = trpc.viewer.credentials.delete.useMutation({ onSuccess: () => { showToast(t("app_removed_successfully"), "success"); - onSuccess && onSuccess(); + onSuccess?.(); setConfirmationDialogOpen(false); }, onError: () => { @@ -52,12 +52,12 @@ export function MultiDisconnectIntegration({ credentials, onSuccess }: Props) { }, }); - const getUserDisplayName = (user: (typeof credentials)[number]["user"]) => { + const getUserDisplayName = (user: (typeof credentials)[number]["user"]): string | null => { if (!user) return null; - // Check if 'name' property exists on user - if ("name" in user) return user.name; - // Otherwise use email if available - if ("email" in user) return user.email; + // Check if 'name' property exists and has a truthy string value + if ("name" in user && typeof user.name === "string" && user.name) return user.name; + // Otherwise use email if available and it's a string + if ("email" in user && typeof user.email === "string" && user.email) return user.email; return null; }; diff --git a/packages/app-store/delegationCredential.test.ts b/packages/app-store/delegationCredential.test.ts index 8f35b14757..0198402b23 100644 --- a/packages/app-store/delegationCredential.test.ts +++ b/packages/app-store/delegationCredential.test.ts @@ -114,7 +114,7 @@ const buildDelegationCredential = (overrides = {}) => ({ id: -1, delegatedToId: mockDelegationCredential.id, userId: mockUser.id, - user: { email: mockUser.email }, + user: { email: mockUser.email, name: null }, key: { access_token: "NOOP_UNUSED_DELEGATION_TOKEN" }, invalid: false, teamId: null, diff --git a/packages/app-store/delegationCredential.ts b/packages/app-store/delegationCredential.ts index 979d493688..1ef722e6a7 100644 --- a/packages/app-store/delegationCredential.ts +++ b/packages/app-store/delegationCredential.ts @@ -87,6 +87,7 @@ const _buildCommonUserCredential = ({ userId: user.id, user: { email: user.email, + name: null as string | null, }, key: { access_token: "NOOP_UNUSED_DELEGATION_TOKEN",