## 1. Preconditions

- [x] 1.1 Settle whether employees who have left belong in a request's roster. They do, and already are everywhere — they are marked `quit_job` rather than deleted, and no overtime code reads that column. An earlier draft had them excluded on a misreading of the soft-delete trait; see Decision 6 of design.md.
- [x] 1.2 Note the ordering constraint: this change must not reach an environment before `add-overtime-workday-input` task 7.11, which drops the employee restriction from the manager's two month figures. Shipping this first puts a row of faces above a count of two. Resolved — 7.11 is done and sits in the same branch.

## 2. The preview

- [x] 2.1 Load the preview without reading a request's whole roster: take the pivot rows for the page's requests, keep the first `EMPLOYEE_PREVIEW_LIMIT` account ids per request, and load only those employees. Slicing a fully loaded relation reads exactly what the cap exists to avoid — see Decision 4 of design.md.
- [x] 2.2 Order the pivot deterministically, by account id or by the pivot's own key, so the same employees appear in the same order on every read rather than in whatever order the database returns.
- [x] 2.3 Load the previewed employees with `Account::$relationData['simple_employee']` — name, avatar, employee code — rather than the `simple_employee_detail` the `accounts()` relation carries, which adds the position, department and company chain that no avatar needs.
- [x] 2.4 Report the preview on each row of `Employee/OvertimeRequestController@index`.
- [x] 2.5 Report the total alongside it, counted over the same set the preview is drawn from — a total scoped differently would make the remainder wrong in a way nothing on screen reveals.
- [x] 2.6 Reach `accounts` for both the preview and the total rather than trusting the pivot: deleting an account leaves its pivot rows behind, because the delete path turns foreign key checks off before a hard delete. A count off the pivot would include those rows, and a preview picking ids from it would spend slots on accounts that cannot be loaded. See Decision 6 of design.md.

## 3. Documentation of what already works

- [x] 3.1 Document `q`, `from`, `to`, `created_from` and `created_to` on the OpenAPI annotation for `Employee/OvertimeRequestController@index`. All five are honoured by `filterByRequest()` today and none is described there.
- [x] 3.2 Note for the client that `q` matches a request's title as well as an employee's name or code, so a field labelled for employees alone will surprise whoever types a title. The administrator's screen labels its box "title, code, employee name".
- [x] 3.3 Note for the client that `from`/`to` select by the overtime date while `created_from`/`created_to` select by when the request was raised.

## 4. Tests

- [x] 4.1 A request covering one employee previews that one and totals one; three employees preview three and total three; twelve preview ten and total twelve.
- [x] 4.2 A previewed employee carries a name, an avatar and an employee code, and does not carry the position, department or company chain.
- [x] 4.3 **Own-team scope** (amended by `fix-overtime-manager-scope`): a request covering five employees of whom two report to a given manager previews and totals two for that manager, and a second manager leading two of the others sees their own two.
- [x] 4.4 A request covering none of a manager's employees does not appear in their listing.
- [x] 4.5 The preview is stable: listing the same page twice returns the same employees in the same order.
- [x] 4.6 **Cost:** a page containing a request that covers several hundred employees is produced in a query count that does not grow with that number, and the response carries only the previewed employees. Assert the query count, not the elapsed time. Done — `testQueryCountDoesNotGrowWithRosterSize` reads a roster of three hundred in exactly the query count a roster at the cap costs. Getting there needed two settings reads taken off the per-model path; see task 5.2.
- [x] 4.7 Filters: searching by employee name, by employee code and by request title each return the expected requests; a date range selects by overtime date and not by the date raised; two filters given together both apply. Done — the code search now has a code to find (the fixtures set one), so the assertion can no longer skip itself.
- [x] 4.8 Regression: a listing requested with no filter returns what it returned before this change, with the two new fields added and nothing else altered. Done — the row's keys are asserted as a whole, so a field added or dropped elsewhere surfaces here.
- [x] 4.9 A request holding a link to an account that no longer exists previews and totals only the employees that do exist, and the two still agree. Orphan links are reachable: the delete path disables foreign key checks, so the pivot's cascade never fires.
- [x] 4.10 An employee marked `quit_job` still appears in the preview and the total, as they do in the month's figures today.

## 5. Verification

- [ ] 5.1 Confirm against real data that the manager's listing and the month tile agree — the number of faces and the employee count tell the same story.
- [ ] 5.2 Check a page of thirty rows for payload size and query count against the same page before the change. The "after" figures are measured: a page of thirty requests over a roster of twelve costs **10 queries** and **77 KB**, and the query count does not move with the roster (task 4.6 asserts that). Getting there needed two settings reads taken off the per-model path — `fullname_format`, read once per profile serialised, and `display_employee_info_cols`, read by `Account::__construct()` once per account hydrated anywhere in the application. Both are now memoised for the life of the request and dropped on any settings write. What is left is the comparison against the same page on `develop`, which needs the real data.
- [x] 5.3 Report to the `add-overtime-workday-input` change that `sumOvertimeDuration()`'s `whereNull('accounts.deleted_at')` filters an always-empty set and its comment claims a purpose it does not serve. Done — the clause stays, and the comment now says what it does: `Account` uses `SoftDeletes`, so the clause keeps the time_range half agreeing with the workday half, which resolves its accounts through the model and so passes through the soft-delete scope. The join itself guards the orphan pivot rows a hard delete leaves behind.
