From d9537a99de0fb077fe744482e97efd8eb3bf4962 Mon Sep 17 00:00:00 2001 From: Gabriel Garcia Date: Tue, 2 Jun 2026 09:15:44 +0200 Subject: [PATCH 1/2] fix(contractor-onboarding) - handle empty pricing plans --- src/flows/ContractorOnboarding/api.ts | 45 ++++++++------- .../tests/ContractorOnboarding.test.tsx | 56 +++++++++++++++++++ 2 files changed, 81 insertions(+), 20 deletions(-) diff --git a/src/flows/ContractorOnboarding/api.ts b/src/flows/ContractorOnboarding/api.ts index 115ecf866..e82f557ce 100644 --- a/src/flows/ContractorOnboarding/api.ts +++ b/src/flows/ContractorOnboarding/api.ts @@ -350,25 +350,27 @@ const useEorSubscription = (options?: { enabled?: boolean }) => { (plan) => plan.product.name === 'EOR Monthly', ); - const eorSubscription = { - product: { - identifier: eorProductIdentifier, - short_name: 'EOR', - }, - currency: eorPricingPlan?.price.currency, - price: { - amount: convertFromCents(eorPricingPlan?.price.amount ?? 0), - }, - features: [ - 'Contract between Remote and employee', - 'Remote manages onboarding, payroll, and compliance', - 'Manages taxes, benefits, and time-off tracking', - 'Handles contracts, transfers, and terminations', - ], - description: 'Enables hiring in countries without a local entity', - label: 'Employer of Record', - value: eorProductIdentifier, - }; + const eorSubscription = eorPricingPlan + ? { + product: { + identifier: eorProductIdentifier, + short_name: 'EOR', + }, + currency: eorPricingPlan.price.currency, + price: { + amount: convertFromCents(eorPricingPlan.price.amount), + }, + features: [ + 'Contract between Remote and employee', + 'Remote manages onboarding, payroll, and compliance', + 'Manages taxes, benefits, and time-off tracking', + 'Handles contracts, transfers, and terminations', + ], + description: 'Enables hiring in countries without a local entity', + label: 'Employer of Record', + value: eorProductIdentifier, + } + : null; return { eorSubscription, isLoading: isLoadingPricingPlans }; }; @@ -384,7 +386,10 @@ const addEorToFieldOptions = ( eorSubscription: ReturnType['eorSubscription'], excludeProducts?: ProductType[], ) => { - if (shouldIncludeProduct(eorProductIdentifier, excludeProducts)) { + if ( + eorSubscription && + shouldIncludeProduct(eorProductIdentifier, excludeProducts) + ) { fieldOptions.push({ label: eorSubscription.label, value: eorSubscription.value, diff --git a/src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx b/src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx index 021edc267..a7e32adbc 100644 --- a/src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx +++ b/src/flows/ContractorOnboarding/tests/ContractorOnboarding.test.tsx @@ -2656,6 +2656,62 @@ describe('ContractorOnboardingFlow', () => { expect(eorOption).toBeChecked(); }); }); + + it('should not show Employer of Record option when pricing plans is empty', async () => { + server.use( + http.get('*/v1/countries', () => { + return HttpResponse.json({ + data: [ + { + code: 'PRT', + name: 'Portugal', + eor_onboarding: true, + }, + ], + }); + }), + http.get( + '*/v1/contractors/employments/*/contractor-subscriptions', + () => { + return HttpResponse.json(mockCMOnlyResponse); + }, + ), + http.get('*/v1/companies/*/pricing-plans', () => { + return HttpResponse.json({ + data: { + pricing_plans: [], + }, + }); + }), + ); + + mockRender.mockImplementation( + createMockRenderImplementation(MultiStepFormWithoutCountry), + ); + + render( + , + { wrapper: TestProviders }, + ); + + await screen.findByText(/Step: Basic Information/i); + await fillBasicInformation(); + + const nextButton = screen.getByText(/Next Step/i); + nextButton.click(); + + await screen.findByText(/Step: Pricing Plan/i); + await waitForElementToBeRemoved(() => screen.getByTestId('spinner')); + + const eorOption = screen.queryByRole('radio', { + name: /Employer of Record/i, + }); + expect(eorOption).not.toBeInTheDocument(); + }); }); describe('COR Contract Preview Skip', () => { From 702a12e3262ea23be92d917423a1c6c916b6edc6 Mon Sep 17 00:00:00 2001 From: Gabriel Garcia Date: Tue, 2 Jun 2026 09:29:20 +0200 Subject: [PATCH 2/2] fix bug --- src/flows/ContractorOnboarding/api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/flows/ContractorOnboarding/api.ts b/src/flows/ContractorOnboarding/api.ts index e82f557ce..5f264dde0 100644 --- a/src/flows/ContractorOnboarding/api.ts +++ b/src/flows/ContractorOnboarding/api.ts @@ -462,7 +462,8 @@ export const useContractorSubscriptionSchemaField = ( }); const hasAvailableOptions = - filteredContractorSubscriptions.length > 0 || showEorSubscription; + filteredContractorSubscriptions.length > 0 || + (showEorSubscription && eorSubscription !== null); const form = createHeadlessForm( selectContractorSubscriptionStepSchema.data.schema,