## Context

### What a manager's screen reaches

```php
// OvertimeRequest.php:148
public function scopeFilterByManager($query, $manager) {
    return $query->filterByAccounts($manager->getAllMyEmployeeIds());
}
// → whereHas('accounts', fn ($q) => $q->whereIn('accounts.id', $ids))
```

`whereHas` narrows the **requests**, never the employees inside one. A request reaches the screen when it covers at least one of the manager's employees, and may cover any number of others: raised by a different manager over an overlapping group, or by `getApplicableAccountsByRequest()` with no department, position or employee named, which attaches every employee of the company.

### Where the figures stand now

| | Scope today | After |
|---|---|---|
| Preview on the list | whole roster | the manager's own |
| `accounts_count` | whole roster | the manager's own |
| `total_employee_on_month` | whole roster | the manager's own |
| `total_time_on_month` | whole roster | the manager's own |
| `GET /{id}/accounts` | whole roster | unchanged |

`total_employee_on_month` carried `Account::staffOf($user->id)` from before this body of work; it was removed by `add-overtime-workday-input` task 7.11 and comes back here.

### The cost of knowing who a manager leads

`Account::getAllMyEmployeeIds()` is a recursive CTE walking the leader tree three levels deep (`Account.php:1145`). It is not a column and not cheap. `filterByManager()` already calls it once per request to the endpoint; narrowing the preview and both figures would call it again each time.

## Goals / Non-Goals

**Goals:**
- A manager's figures describe their own team.
- The faces on the list are people that manager is responsible for.
- Resolve the manager's employees once per request to the endpoint.

**Non-Goals:**
- Changing which requests a manager can see.
- The detail of a single request. See Decision 2.
- The administrator's screens, which have no manager to scope to.

## Decisions

### 1. The list and the monthly figures narrow to the manager's own employees

Preview, `accounts_count`, `total_employee_on_month` and `total_time_on_month` all count the same set: the employees of the request that this manager leads.

*Why this reverses the earlier reading.* `add-overtime-list-employee-preview` Decision 1 argued that a request is one object with one roster, and that showing a filtered view makes the same request look different to two managers. That is true, and it is the wrong thing to optimise for. A manager's list is not a catalogue of requests; it is a view of their own team's overtime. The figure a manager acts on — how much overtime my team did this month — was being inflated by employees they are not responsible for, and the faces beside it were people they cannot act on.

*What it costs:* two managers sharing a request see different counts for it. That is correct once the screen is understood as a team view, but it does mean the number on a row is not a property of the request.

*What it restores:* `total_employee_on_month` worked this way before any of this work. The reversal puts it back and brings the other three into line, so the four agree for the first time.

### 2. The detail of a request keeps showing everyone

`GET /employee/overtime_requests/{id}/accounts` is untouched. Opening a request covering five employees still lists five.

*Why the asymmetry is deliberate:* the list answers "what did my team do", the detail answers "what is this request". Those are different questions and the second is the reason to open it — a detail that showed no more than the row above it would be worth nothing. A manager who sees two faces on a row and five on the detail learns something true: this overtime was raised across teams.

*What this gives up:* the row and the detail disagree, and nothing on the row says so. The alternative — narrowing the detail too — was considered and rejected: it would hide from the manager the fact that the request extends beyond their team, which is information they plausibly need when questioning it.

### 3. `accounts_count` counts the narrowed set, not the true total

The total beside the preview is the number of the manager's own employees the request covers, so a request covering five of whom two are theirs reports two, with no remainder.

*Why not report the true total:* a remainder of `+3` over faces the manager cannot open is worse than no remainder at all. It names the existence of employees the screen will not show and the detail will. Counting the shown set keeps the row internally consistent: faces, count and the tile above all describe one group.

*What this gives up:* the row no longer tells a manager that the request extends past their team. Decision 2 leaves that discoverable by opening it.

### 4. The manager's employees are resolved once per request

`getAllMyEmployeeIds()` runs once and the result is passed to everything that needs it, rather than each caller asking again.

*Why it matters:* `filterByManager()` already calls it. Adding the preview and both figures would take `index()` to two calls and `getSummary()` to three, each a recursive CTE over the leader tree. The endpoints should resolve the set once and hand it down — `attachEmployeePreview()` and `sumOvertimeDuration()` each take it as an argument rather than deriving it.

*A detail worth stating:* the set must be the same one `filterByManager()` used. Resolving it twice in one request could in principle disagree, and the row would then show employees the query did not select for.

## Risks / Trade-offs

**Two monthly figures a client already shows will fall** → For any request spanning teams. It is a correction — the figures were counting employees the manager does not lead — but it is visible, and belongs in the release notes alongside the earlier note that they rose.

**The row and the detail disagree** → Decision 2, accepted. Worth telling testers explicitly, because "the list says 2 and the detail says 5" reads as a bug to anyone who has not been told.

**The narrowing is applied in one place and missed in another** → Four figures must describe the same set. If the preview narrows and `accounts_count` does not, the remainder is wrong in a way nothing on screen reveals. A test should assert all four together for one request.

**Resolving the manager's employees twice** → Decision 4. Beyond the cost, two resolutions could disagree, and the preview would then show employees the listing query did not select.

## Open Questions

None.
