Skip to content

fix: block switching between unlimited and accrual-based time off policy types#1900

Merged
jeffredodd merged 1 commit into
mainfrom
kw/timeoff-sick-to-unlimited
May 22, 2026
Merged

fix: block switching between unlimited and accrual-based time off policy types#1900
jeffredodd merged 1 commit into
mainfrom
kw/timeoff-sick-to-unlimited

Conversation

@krisxcrash

@krisxcrash krisxcrash commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When editing a complete unlimited time off policy, all accrual method radio buttons are now disabled — no switching is possible.
  • When editing a complete accrual-based policy, the "Unlimited" radio is disabled, but switching between "Based on hours worked" and "Fixed amount per year" is still allowed.
  • Incomplete policies (still in the creation wizard) remain unrestricted.
  • Adds a helper text explaining that the accrual type cannot be changed and to create a new policy instead.

This matches gws-flows behavior where switching between fundamentally different policy types is blocked because migrating all settings is too complex — users should create a new policy and reassign employees.

Applies to both sick and vacation policy types (the component handles both via policyType prop).

Test plan

  • All existing PolicyConfigurationForm.test.tsx tests pass (45/45)
  • Manually verify: edit a complete unlimited policy → accrual method radios are all disabled
  • Manually verify: edit a complete accrual-based policy → "Unlimited" radio is disabled, other two are clickable
  • Manually verify: creating a new policy → all options remain available

@krisxcrash krisxcrash force-pushed the kw/timeoff-sick-to-unlimited branch from 70fc8a0 to b66082d Compare May 21, 2026 23:01
@krisxcrash krisxcrash changed the title fix: allow switching existing sick/vacation policy to unlimited accrual fix: block switching between unlimited and accrual-based time off policy types May 21, 2026
@krisxcrash krisxcrash self-assigned this May 21, 2026
@krisxcrash krisxcrash marked this pull request as ready for review May 21, 2026 23:02
@krisxcrash krisxcrash requested a review from a team as a code owner May 21, 2026 23:02
@gusto-fresh-eyes

gusto-fresh-eyes Bot commented May 21, 2026

Copy link
Copy Markdown

Fresh Eyes Review

Found 1 issue in this PR.

Download findings.json — drag the file into Claude or use /add to propose fixes


Please 👍🏽 👎🏽 if you found this useful. Generated by Fresh Eyes Reviewer. Get help in #ai-code-reviews

@@ -166,7 +166,6 @@ function buildUpdateRequestBody(
accrualRate: null,
accrualRateUnit: null,
policyResetDate: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Minor | [fresh_eyes]: description-check

Undocumented behavioral change: complete: true was removed from the request body in buildUpdateRequestBody when switching to unlimited. This changes what gets sent to the API (previously the policy was marked complete on switch-to-unlimited). The change makes sense given that switching is now only possible for incomplete policies, but this wire-format change should be noted in the PR description.


Please 👍🏽 👎🏽 if you found this useful. Generated by Fresh Eyes Reviewer. Get help in #ai-code-reviews

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intentional change. With the new locking logic, only incomplete policies can reach this code path (complete policies have the "Unlimited" radio disabled). Sending complete: true for an incomplete policy would incorrectly mark it as complete just because the user selected unlimited accrual — completeness is handled elsewhere in the creation wizard flow.

Comment thread src/types/i18next.d.ts
"rate":string;
"nonZeroRate":string;
"rateExemptThreshold":string;
"title":string;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Minor | [fresh_eyes]: description-check

Undocumented change: Two unrelated translation keys (effectiveDate and effectiveDateBeforeHire) were removed from the EmployeeCompensation type. This is unrelated to the time off policy changes described in the PR. Likely a side effect of running npm run i18n:generate, but should be acknowledged in the description or split out.


Please 👍🏽 👎🏽 if you found this useful. Generated by Fresh Eyes Reviewer. Get help in #ai-code-reviews

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a correct deduplication from running npm run i18n:generate. The source JSON (Employee.Compensation.json) has duplicate keys for effectiveDate and effectiveDateBeforeHire in the validations object (lines 68-69 and 80-81). The old generated types had duplicate interface properties — regenerating correctly produces one entry per key. No translation was actually removed; the runtime behavior is unchanged (JSON.parse uses the last occurrence).

@jeffredodd jeffredodd force-pushed the kw/timeoff-sick-to-unlimited branch from b66082d to a1eec68 Compare May 22, 2026 16:10
@jeffredodd jeffredodd enabled auto-merge (squash) May 22, 2026 16:35
@jeffredodd jeffredodd force-pushed the kw/timeoff-sick-to-unlimited branch 2 times, most recently from e6f7d7b to b4d1b9e Compare May 22, 2026 16:46
…icy types

When editing a complete time off policy, prevent changing between
unlimited and accrual-based accrual types in the UI:

- Complete unlimited policies: all accrual method radios are disabled
- Complete accrual-based policies: the "Unlimited" radio is disabled,
  but switching between "Based on hours worked" and "Fixed amount per
  year" is still allowed
- Incomplete policies (still in creation wizard): no restrictions

This matches the behavior in gws-flows, where the assumption is that
migrating settings between these fundamentally different policy types
is too complex. Users should create a new policy instead.
@jeffredodd jeffredodd force-pushed the kw/timeoff-sick-to-unlimited branch from b4d1b9e to e9b6e7d Compare May 22, 2026 16:49
@jeffredodd jeffredodd merged commit b3e737b into main May 22, 2026
21 of 25 checks passed
@jeffredodd jeffredodd deleted the kw/timeoff-sick-to-unlimited branch May 22, 2026 16:55
@@ -166,7 +166,6 @@ function buildUpdateRequestBody(
accrualRate: null,
accrualRateUnit: null,
policyResetDate: null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Minor | [fresh_eyes]: description-check

Undocumented behavioral change: removal of complete: true from buildUpdateRequestBody's unlimited branch changes what's sent to the API (incomplete policies switching to unlimited no longer get force-marked as complete). The PR description only mentions UI locking of radio buttons but doesn't explain this API-level change or why it's correct.


Please 👍🏽 👎🏽 if you found this useful. Generated by Fresh Eyes Reviewer. Get help in #ai-code-reviews

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.

2 participants