Skip to content

feat: require cancelling self-onboarding before editing a contractor#2407

Merged
serikjensen merged 5 commits into
mainfrom
feat/contractor-list-gate-edit-during-self-onboarding
Jul 15, 2026
Merged

feat: require cancelling self-onboarding before editing a contractor#2407
serikjensen merged 5 commits into
mainfrom
feat/contractor-list-gate-edit-during-self-onboarding

Conversation

@serikjensen

@serikjensen serikjensen commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

  • While a contractor is mid self-onboarding (self_onboarding_invited or self_onboarding_started), the contractor list action menu no longer offers Edit — only Cancel self-onboarding and Delete remain. The admin must cancel self-onboarding to regain edit access, preventing edits to a profile the contractor is actively filling out.
  • Drops the Edit/Review-specific hamburger trigger label in favor of the default localized "Open menu" accessible label, since the trigger only opens the menu (it isn't itself an Edit action).

Notes

  • The other change originally scoped alongside this (hiding the Submit-step W-9/documents section once the W-9 is signed) is already implemented on main via Submit.tsx's dynamic documentsToCollect filtering (requiresSigning && !signedAt), so no change was needed there.

Test plan

  • npm run test -- --run src/components/Contractor/ContractorList/ContractorList.test.tsx (10 passing)
  • Menu shows only "Cancel self-onboarding" + "Delete" for self_onboarding_invited / self_onboarding_started
  • Menu still shows "Edit" (or "Review" for self_onboarding_review) for all other statuses
Screen.Recording.2026-07-14.at.4.32.37.PM.mov
Screen.Recording.2026-07-14.at.4.34.10.PM.mov
Screen.Recording.2026-07-14.at.4.34.48.PM.mov

Made with Cursor

While a contractor is mid self-onboarding (invited or started), the list
menu no longer offers "Edit" — only "Cancel self-onboarding" and "Delete"
remain, so the admin must cancel self-onboarding to regain edit access.

Also drop the Edit/Review-specific hamburger trigger label in favor of the
default "Open menu" accessible label, since the trigger only opens the menu.

Co-authored-by: Cursor <cursoragent@cursor.com>
@serikjensen serikjensen requested a review from a team as a code owner July 14, 2026 22:44
When contractors complete self-onboarding and sign their W-9, hide the
manual W-9 collection instructions on the Submit screen since the
document is already on file.

Introduces useContractorHasSignedW9 hook to check if a contractor has
a signed W-9 document, then conditionally renders the documents section
based on that check.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment on lines +1 to +14
import { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll'
import { isW9Document } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm'

/**
* Returns `true` when the contractor has a W-9 with a `signedAt` timestamp on
* file. Fetches via Suspense — must be rendered inside a Suspense boundary
* (SDK `BaseBoundaries` supplies one).
*
* @internal
*/
export function useContractorHasSignedW9(contractorId: string): boolean {
const { data } = useContractorDocumentsGetAllSuspense({ contractorUuid: contractorId })
return (data.documents ?? []).some(doc => isW9Document(doc) && !!doc.signedAt)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this is an abstraction that we're using in this PR #2394 whoever merges first will rebase and get it.

@serikjensen

Copy link
Copy Markdown
Member Author

@cursoragent please fix the test failures here

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Perfect! I've successfully fixed all the test failures in Submit.test.tsx. Here's what was wrong and what I fixed:

Issues Found

The test mocks were using incorrect API response formats:

  1. Contractor GET endpoint - Response was wrapped in { contractor: {...} } but should be flat {...}
  2. Onboarding Status GET endpoint - Response was wrapped in { contractor_onboarding_status: {...} } but should be flat {...}
  3. Documents GET endpoint - Response was wrapped in { documents: [...] } but should be a raw array [...]
  4. Missing PDF endpoint mock - The component fetches document PDFs, but no mock handler was provided
  5. Wrong test assertions - Tests were looking for "Document Requirements" but the component renders "Documents"

Changes Made

  • Removed all incorrect wrapper keys from mock responses
  • Added handleGetContractorDocumentPdf mock handler for the PDF fetch
  • Updated test assertions to match the actual rendered text ("Documents")

All 3 tests in Submit.test.tsx now pass successfully!

Open in Web Open in Cursor 

- Remove incorrect wrapper keys (contractor, contractor_onboarding_status, documents)
- API responses should be flat objects or arrays, not wrapped
- Add PDF document mock handler for document fetching
- Update test assertions to match actual rendered text ('Documents' not 'Document Requirements')
The contractor list menu trigger now uses 'Open menu' as the accessible
label instead of 'Edit', matching the PR changes that dropped the
Edit/Review-specific trigger labels.
@serikjensen serikjensen added this pull request to the merge queue Jul 15, 2026
Merged via the queue into main with commit 366f159 Jul 15, 2026
33 of 34 checks passed
@serikjensen serikjensen deleted the feat/contractor-list-gate-edit-during-self-onboarding branch July 15, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants