Make the replacement field optional and neutrally worded on HR-recorded absences - #48
Merged
Merged
Conversation
…absence "Who covers for you?" is the right question when you are booking your own leave. It is the wrong one when HR records an absence for somebody else, and the requirement behind it is wrong there too: the replacement field was mandatory for any requires_replacement type regardless of who was filling the form in. The rule is about the employee, not the record. Somebody arranging their own leave knows who can cover and is asked to sort it out before going. HR recording or correcting an absence for somebody else is stating a fact, often after the event, and cannot nominate cover on that person's behalf. So the field is now offered but not demanded on those paths, and reads "Who is the replacement?" with an (optional) marker and a hint naming the employee. The wording keys off whose leave it is rather than off HR mode, so HR recording their *own* absence — possible since #47 — still gets "Who covers for you?" and the requirement that goes with it. Also closes a hole found while restructuring the check: for a type that did not require a replacement, whatever was submitted was stored unvalidated, so a guest or the employee themselves could be recorded as covering. Only the *demand* is conditional; who may be named never was. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
"Who covers for you?" is the right question when you are booking your own leave. It is the wrong one when HR records an absence for somebody else — and the requirement behind it was wrong there too: the replacement field was mandatory for any
requires_replacementtype regardless of who was filling the form in.The rule belongs to the employee, not to the record
Somebody arranging their own leave knows who can cover and is asked to sort it out before going (§5.1). HR recording or correcting an absence for somebody else is stating a fact, often after the event, and cannot nominate cover on that person's behalf.
So on those paths the field is now offered but never demanded, and reads:
Replacement *Replacement (optional)The hint follows too — "Optional. A colleague who covers for Lea while they are away, and is notified once this is recorded."
The wording keys off whose leave it is, not off HR mode. So HR recording their own absence — possible since #47 — still gets "Who covers for you?" and the requirement that goes with it, which raw
hrModewould have got wrong.Enforced on both sides, not just hidden:
resolveReplacement()takes arequiredflag, false fromcreate()whenonBehalfand fromhrEdit(). Without the server half the dialog would allow submit and the API would then reject it.Also closes a hole
Found while restructuring the check. For a type that did not require a replacement, whatever was submitted was stored unvalidated:
The guest and self checks sat below that early return, so a guest — or the employee themselves — could be recorded as covering, on sick leave for instance. The method's own docblock claimed "Also rejects guests". Only the demand is conditional; who may be named never was, and now isn't.
Testing
174 tests, 483 assertions, 0 failures (3 new). Each was checked against the original code: the HR-records-for-someone-else case errors without the
requiredflag, and the guest case fails without the restructure. The third pins that self-service still demands a replacement, so the loosening did not leak into the employee path.eslint 0 errors, stylelint clean, 27/27 vitest, build succeeds. Bundles recompiled in the last commit.
🤖 Generated with Claude Code