From ed40a5b3a024920bd622679748fa6833cf9e235e Mon Sep 17 00:00:00 2001 From: Kristine White Date: Tue, 6 Jan 2026 12:46:11 -0800 Subject: [PATCH 1/2] feat: hide direct deposit for employees without account set up --- .../PayrollEditEmployee.tsx | 7 ++ .../PayrollEditEmployeePresentation.test.tsx | 82 +++++++++++++++++++ .../PayrollEditEmployeePresentation.tsx | 42 +++++----- 3 files changed, 112 insertions(+), 19 deletions(-) diff --git a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx index 9a8d82889..add5ce6d2 100644 --- a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx +++ b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx @@ -1,4 +1,5 @@ import { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet' +import { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts' import { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate' import type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype' import type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate' @@ -39,6 +40,9 @@ export const Root = ({ const { LoadingIndicator, baseSubmitHandler } = useBase() const { data: employeeData } = useEmployeesGetSuspense({ employeeId }) + const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({ + employeeId, + }) const memoizedEmployeeId = useMemo(() => [employeeId], []) const { preparedPayroll, paySchedule, isLoading } = usePreparedPayrollData({ companyId, @@ -50,6 +54,8 @@ export const Root = ({ const employee = employeeData.employee! const employeeCompensation = preparedPayroll?.employeeCompensations?.at(0) + const bankAccounts = bankAccountsList.employeeBankAccountList || [] + const hasDirectDepositSetup = bankAccounts.length > 0 const transformEmployeeCompensation = ({ paymentMethod, @@ -103,6 +109,7 @@ export const Root = ({ paySchedule={paySchedule} isOffCycle={preparedPayroll?.offCycle} withReimbursements={withReimbursements} + hasDirectDepositSetup={hasDirectDepositSetup} /> ) } diff --git a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx index af3908de5..96ab49625 100644 --- a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx +++ b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx @@ -1033,4 +1033,86 @@ describe('PayrollEditEmployeePresentation', () => { }) }) }) + + describe('Payment Method Visibility Based on Direct Deposit Setup', () => { + it('shows payment method control when employee has direct deposit set up', () => { + renderWithProviders( + , + ) + + expect(screen.getByText('Payment method')).toBeInTheDocument() + expect(screen.getByLabelText('Direct deposit')).toBeInTheDocument() + expect(screen.getByLabelText('Check')).toBeInTheDocument() + }) + + it('hides payment method control when employee does not have direct deposit set up', () => { + renderWithProviders( + , + ) + + expect(screen.queryByText('Payment method')).not.toBeInTheDocument() + expect(screen.queryByLabelText('Direct deposit')).not.toBeInTheDocument() + expect(screen.queryByLabelText('Check')).not.toBeInTheDocument() + }) + + it('shows payment method control by default when hasDirectDepositSetup is not provided', () => { + const propsWithoutDirectDepositFlag = { + ...defaultProps, + hasDirectDepositSetup: undefined, + } + + renderWithProviders() + + expect(screen.getByText('Payment method')).toBeInTheDocument() + expect(screen.getByLabelText('Direct deposit')).toBeInTheDocument() + expect(screen.getByLabelText('Check')).toBeInTheDocument() + }) + + it('allows form submission without payment method when employee has no direct deposit', async () => { + const compensationWithCheckPayment = { + ...mockEmployeeCompensation, + paymentMethod: PaymentMethods.Check, + } + + renderWithProviders( + , + ) + + const user = userEvent.setup() + const saveButton = screen.getByRole('button', { name: 'Save' }) + await user.click(saveButton) + + await waitFor(() => { + expect(defaultProps.onSave).toHaveBeenCalled() + }) + + expect(defaultProps.onSave).toHaveBeenCalledWith( + expect.objectContaining({ + paymentMethod: PaymentMethods.Check, + }), + ) + }) + + it('does not allow changing payment method when employee has no direct deposit', () => { + const compensationWithCheckPayment = { + ...mockEmployeeCompensation, + paymentMethod: PaymentMethods.Check, + } + + renderWithProviders( + , + ) + + expect(screen.queryByLabelText('Direct deposit')).not.toBeInTheDocument() + expect(screen.queryByLabelText('Check')).not.toBeInTheDocument() + }) + }) }) diff --git a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.tsx b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.tsx index b28000281..c38636a24 100644 --- a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.tsx +++ b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.tsx @@ -49,6 +49,7 @@ interface PayrollEditEmployeeProps { paySchedule?: PayScheduleObject isOffCycle?: boolean withReimbursements?: boolean + hasDirectDepositSetup?: boolean } export const PayrollEditEmployeeFormSchema = z.object({ @@ -134,6 +135,7 @@ export const PayrollEditEmployeePresentation = ({ paySchedule, isOffCycle = false, withReimbursements = true, + hasDirectDepositSetup = true, }: PayrollEditEmployeeProps) => { const { Button, Heading, Text } = useComponentContext() @@ -472,25 +474,27 @@ export const PayrollEditEmployeePresentation = ({ )} -
- {t('paymentMethodTitle')} - -
+ {hasDirectDepositSetup && ( +
+ {t('paymentMethodTitle')} + +
+ )} {!isSmallOrGreater && actions} From 98bb62917bdd654bcfd4506b2d72742d15f253e5 Mon Sep 17 00:00:00 2001 From: Kristine White Date: Wed, 7 Jan 2026 10:28:56 -0800 Subject: [PATCH 2/2] fix: removed dupe test --- .../PayrollEditEmployeePresentation.test.tsx | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx index 96ab49625..4280565a1 100644 --- a/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx +++ b/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.test.tsx @@ -1096,23 +1096,5 @@ describe('PayrollEditEmployeePresentation', () => { }), ) }) - - it('does not allow changing payment method when employee has no direct deposit', () => { - const compensationWithCheckPayment = { - ...mockEmployeeCompensation, - paymentMethod: PaymentMethods.Check, - } - - renderWithProviders( - , - ) - - expect(screen.queryByLabelText('Direct deposit')).not.toBeInTheDocument() - expect(screen.queryByLabelText('Check')).not.toBeInTheDocument() - }) }) })