From 1fa88ea664056f1d093dda0cf20a3656715c9c82 Mon Sep 17 00:00:00 2001
From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com>
Date: Wed, 7 Jan 2026 18:57:52 -0300
Subject: [PATCH 1/3] Flip boolean check
---
packages/ui/src/common/CreateOrganizationAction.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/ui/src/common/CreateOrganizationAction.tsx b/packages/ui/src/common/CreateOrganizationAction.tsx
index 253c98b477f..807fb7eedd6 100644
--- a/packages/ui/src/common/CreateOrganizationAction.tsx
+++ b/packages/ui/src/common/CreateOrganizationAction.tsx
@@ -11,7 +11,7 @@ export const CreateOrganizationAction = (props: CreateOrganizationActionProps) =
const { organizationSettings } = useEnvironment();
const currentMembershipCount = (user?.organizationMemberships ?? []).length;
- const canCreateAdditionalMembership = currentMembershipCount < organizationSettings.maxAllowedMemberships;
+ const canCreateAdditionalMembership = organizationSettings.maxAllowedMemberships < currentMembershipCount;
if (!user?.createOrganizationEnabled || !canCreateAdditionalMembership) {
return null;
From 410090658990d1c748b7a3b3e435d4a5276980e2 Mon Sep 17 00:00:00 2001
From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com>
Date: Wed, 7 Jan 2026 19:01:01 -0300
Subject: [PATCH 2/3] Add tests
---
.../src/common/CreateOrganizationAction.tsx | 3 +-
.../__tests__/OrganizationSwitcher.test.tsx | 51 +++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/packages/ui/src/common/CreateOrganizationAction.tsx b/packages/ui/src/common/CreateOrganizationAction.tsx
index 807fb7eedd6..328981b22b9 100644
--- a/packages/ui/src/common/CreateOrganizationAction.tsx
+++ b/packages/ui/src/common/CreateOrganizationAction.tsx
@@ -11,7 +11,8 @@ export const CreateOrganizationAction = (props: CreateOrganizationActionProps) =
const { organizationSettings } = useEnvironment();
const currentMembershipCount = (user?.organizationMemberships ?? []).length;
- const canCreateAdditionalMembership = organizationSettings.maxAllowedMemberships < currentMembershipCount;
+ const canCreateAdditionalMembership =
+ !organizationSettings.maxAllowedMemberships || currentMembershipCount < organizationSettings.maxAllowedMemberships;
if (!user?.createOrganizationEnabled || !canCreateAdditionalMembership) {
return null;
diff --git a/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx b/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
index a6a7750f1ab..5c26e18ca1d 100644
--- a/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
+++ b/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
@@ -308,6 +308,57 @@ describe('OrganizationSwitcher', () => {
expect(queryByText('Create organization')).not.toBeInTheDocument();
});
+ it('does not allow creating organization if max allowed memberships is reached', async () => {
+ const { wrapper, props } = await createFixtures(f => {
+ f.withOrganizations();
+ f.withMaxAllowedMemberships({ max: 1 });
+ f.withUser({
+ email_addresses: ['test@clerk.com'],
+ create_organization_enabled: true,
+ organization_memberships: [{ name: 'Org1', id: '1', role: 'admin' }],
+ });
+ });
+
+ props.setProps({ hidePersonal: true });
+ const { queryByText, getByRole, userEvent } = render(, { wrapper });
+ await userEvent.click(getByRole('button', { name: 'Open organization switcher' }));
+ expect(queryByText('Create organization')).not.toBeInTheDocument();
+ });
+
+ it('does allow creating organization if max allowed memberships is not reached', async () => {
+ const { wrapper, props } = await createFixtures(f => {
+ f.withOrganizations();
+ f.withMaxAllowedMemberships({ max: 2 });
+ f.withUser({
+ email_addresses: ['test@clerk.com'],
+ create_organization_enabled: true,
+ organization_memberships: [{ name: 'Org1', id: '1', role: 'admin' }],
+ });
+ });
+
+ props.setProps({ hidePersonal: true });
+ const { queryByText, getByRole, userEvent } = render(, { wrapper });
+ await userEvent.click(getByRole('button', { name: 'Open organization switcher' }));
+ expect(queryByText('Create organization')).toBeInTheDocument();
+ });
+
+ it('does allow creating organization if max allowed memberships is unlimited', async () => {
+ const { wrapper, props } = await createFixtures(f => {
+ f.withOrganizations();
+ f.withMaxAllowedMemberships({ max: 0 });
+ f.withUser({
+ email_addresses: ['test@clerk.com'],
+ create_organization_enabled: true,
+ organization_memberships: [{ name: 'Org1', id: '1', role: 'admin' }],
+ });
+ });
+
+ props.setProps({ hidePersonal: true });
+ const { queryByText, getByRole, userEvent } = render(, { wrapper });
+ await userEvent.click(getByRole('button', { name: 'Open organization switcher' }));
+ expect(queryByText('Create organization')).toBeInTheDocument();
+ });
+
it.each([
['Admin', 'admin'],
['Member', 'basic_member'],
From 065a45b3c911d208d380330fbff79302e5f66279 Mon Sep 17 00:00:00 2001
From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com>
Date: Wed, 7 Jan 2026 19:10:15 -0300
Subject: [PATCH 3/3] Add changeset
---
.changeset/some-donkeys-dress.md | 6 ++++++
.../__tests__/OrganizationSwitcher.test.tsx | 17 -----------------
2 files changed, 6 insertions(+), 17 deletions(-)
create mode 100644 .changeset/some-donkeys-dress.md
diff --git a/.changeset/some-donkeys-dress.md b/.changeset/some-donkeys-dress.md
new file mode 100644
index 00000000000..e3af20029af
--- /dev/null
+++ b/.changeset/some-donkeys-dress.md
@@ -0,0 +1,6 @@
+---
+'@clerk/clerk-js': patch
+'@clerk/ui': patch
+---
+
+Allow creating additional memberships on unlimited `environment.organizationSettings.maxAllowedMemberships`
diff --git a/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx b/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
index 5c26e18ca1d..fd9b6178c51 100644
--- a/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
+++ b/packages/ui/src/components/OrganizationSwitcher/__tests__/OrganizationSwitcher.test.tsx
@@ -291,23 +291,6 @@ describe('OrganizationSwitcher', () => {
expect(getByText('Org2')).toBeInTheDocument();
});
- it('does not allow creating organization if not allowed to create additional membership', async () => {
- const { wrapper, props } = await createFixtures(f => {
- f.withOrganizations();
- f.withMaxAllowedMemberships({ max: 1 });
- f.withUser({
- email_addresses: ['test@clerk.com'],
- create_organization_enabled: true,
- organization_memberships: [{ name: 'Org1', id: '1', role: 'admin' }],
- });
- });
-
- props.setProps({ hidePersonal: true });
- const { queryByText, getByRole, userEvent } = render(, { wrapper });
- await userEvent.click(getByRole('button', { name: 'Open organization switcher' }));
- expect(queryByText('Create organization')).not.toBeInTheDocument();
- });
-
it('does not allow creating organization if max allowed memberships is reached', async () => {
const { wrapper, props } = await createFixtures(f => {
f.withOrganizations();