Skip to main content

useEmployeeList

useEmployeeList(input: UseEmployeeListProps): UseEmployeeListResult

Fetches a paginated list of a company's employees and decorates each entry with the actions allowed for its current onboarding state.

Remarks

employeeType maps to a server-side filter and changes which actions appear on each row: 'active' adds dismiss, 'terminated' adds rehire, 'onboarding' adds none. Omit it to list every employee.

Page changes use placeholder data: the previous page stays rendered while the next one loads, and status.isFetching flips to true during the request.

Example

Example
import { useEmployeeList } from '@gusto/embedded-react-sdk'

function EmployeeListPage({ companyId }: { companyId: string }) {
const employeeList = useEmployeeList({ companyId, employeeType: 'onboarding' })

if (employeeList.isLoading) return <div>Loading...</div>

return (
<ul>
{employeeList.data.employees.map(employee => (
<li key={employee.uuid}>
{employee.firstName} {employee.lastName}
{employee.allowedActions.includes('delete') && (
<button onClick={() => employeeList.actions.onDelete(employee.uuid)}>Delete</button>
)}
</li>
))}
</ul>
)
}

Props

UseEmployeeListProps

Props for useEmployeeList.

PropertyTypeDescription
companyIdstringThe associated company identifier.
employeeType?EmployeeTypeFilters the list and tailors the allowed actions. Omit to list all employees.

Returns

UseEmployeeListResult

A HookLoadingResult while the first page is in flight, or a UseEmployeeListReady once data has arrived.

UseEmployeeListResult

UseEmployeeListResult = HookLoadingResult | UseEmployeeListReady

Return type of useEmployeeList.


UseEmployeeListReady

Ready state of useEmployeeList.

PropertyTypeDescription
actionsobjectActions that mutate an employee's state, gated by the entry's allowedActions.
actions.onCancelSelfOnboarding(employeeId: string) => Promise<EmployeeOnboardingStatus | undefined>Reverts a self-onboarding employee to admin-driven onboarding. Resolves to the updated record, or undefined if the call failed.
actions.onDelete(employeeId: string) => Promise<void>Deletes the employee.
actions.onReview(employeeId: string) => Promise<EmployeeOnboardingStatus | undefined>Moves the employee into the admin-review onboarding status. Resolves to the updated record, or undefined if the call failed.
dataobjectHook-specific data payload; shape is narrowed by each concrete hook via TData.
data.employeesEmployeeWithActions[]-
errorHandlingHookErrorHandlingError state and recovery actions.
isLoadingfalseAlways false in this branch; discriminates from HookLoadingResult.
paginationPaginationControlPropsPagination controls for the current employee list page.
statusobjectHook-specific status flags; shape is narrowed by each concrete hook via TStatus.
status.isFetchingboolean-
status.isPendingboolean-

Utility types

EmployeeAction

EmployeeAction = "edit" | "delete" | "cancel_self_onboarding" | "review" | "dismiss" | "rehire"

Action that may be performed on an employee row, determined by the employee's onboarding state and the employeeType filter passed to useEmployeeList.


EmployeeType

EmployeeType = "active" | "onboarding" | "terminated"

Filter applied to useEmployeeList that scopes the result set and tailors the per-row action list.


EmployeeWithActions

An employee entity extended with the actions permitted on it and a reference to its primary job.

Extends

Properties

PropertyTypeDescription
allowedActionsEmployeeAction[]Actions permitted for this employee given its onboarding status and the active filter.
firstNamestring-
lastNamestring-
paymentMethodEmployeePaymentMethod1The employee's payment method
uuidstringThe UUID of the employee in Gusto.
applicableTaxIds?number[]-
companyUuid?stringThe UUID of the company the employee is employed by.
currentEmploymentStatus?CurrentEmploymentStatus | nullThe current employment status of the employee. Full-time employees work 30+ hours per week. Part-time employees are split into two groups: those that work 20-29 hours a week, and those that work under 20 hours a week. Variable employees have hours that vary each week. Seasonal employees are hired for 6 months of the year or less.
customFields?EmployeeCustomField[]Custom fields are only included for the employee if the include param has the custom_fields value set
dateOfBirth?string | null-
department?string | nullThe employee's department in the company.
departmentUuid?string | nullThe UUID of the department the employee is under
eligiblePaidTimeOff?PaidTimeOff[]-
email?string | nullThe personal email address of the employee. This is provided to support syncing users between our system and yours. You may not use this email address for any other purpose (e.g. marketing).
employeeCode?stringThe short format code of the employee
flsaStatus?FlsaStatusTypeThe FLSA status for this compensation. Salaried ('Exempt') employees are paid a fixed salary every pay period. Salaried with overtime ('Salaried Nonexempt') employees are paid a fixed salary every pay period, and receive overtime pay when applicable. Hourly ('Nonexempt') employees are paid for the hours they work, and receive overtime pay when applicable. Commissioned employees ('Commission Only Exempt') earn wages based only on commission. Commissioned with overtime ('Commission Only Nonexempt') earn wages based on commission, and receive overtime pay when applicable. Owners ('Owner') are employees that own at least twenty percent of the company.
garnishments?Garnishment[]-
hasSsn?booleanIndicates whether the employee has an SSN in Gusto.
hiddenSsn?string-
hiredAt?RFCDateThe date when the employee was hired to the company
historical?boolean-
jobs?Job[]-
managerUuid?string | nullThe UUID of the employee's manager.
memberPortalInvitationStatus?EmployeeMemberPortalInvitationStatus | nullMember portal invitation status information. Only included when the include param has the portal_invitations value set.
middleInitial?string | null-
onboarded?booleanWhether the employee has completed onboarding.
onboardingDocumentsConfig?OnboardingDocumentsConfigConfiguration for an employee onboarding documents during onboarding
onboardingStatus?EmployeeOnboardingStatus1 | nullThe current onboarding status of the employee
partnerPortalInvitationSent?boolean | nullWhether an external partner portal invitation webhook has been sent for this employee. Only included when the include param has the portal_invitations value set.
phone?string | null-
preferredFirstName?string | null-
primaryJob?JobThe employee's primary job, if one is marked primary.
ssn?stringDeprecated. This field always returns an empty string.
terminated?booleanWhether the employee is terminated.
terminations?Termination[]-
title?string-
twoPercentShareholder?boolean | nullWhether the employee is a two percent shareholder of the company. This field only applies to companies with an S-Corp entity type.
version?stringThe current version of the employee. See the versioning guide for information on how to use this field.
workEmail?string | nullThe work email address of the employee. This is provided to support syncing users between our system and yours. You may not use this email address for any other purpose (e.g. marketing).

Endpoints