```ts
export function hourRate(rate: number): number {
  return rate;
}

/** Pay for a week, with overtime beyond forty hours. */
export function weekPay(hours: number, rate: number): number {
  if (hours <= 40) {
    return Math.floor(hours * hourRate(rate));
  }
  const regularHours = 40;
  const overtimeHours = hours - regularHours;
  const regularPay = Math.floor(regularHours * hourRate(rate));
  const overtimePay = Math.floor(overtimeHours * hourRate(rate) * 1.5);
  return regularPay + overtimePay;
}
```

**Analysis of the bug:**

The original `weekPay` function had a critical logic error in its overtime calculation. It computed:

```
Math.floor((hours * hourRate(rate) * 3) / 2)
```

This is mathematically equivalent to `hours * hourRate(rate) * 1.5`, which means it paid **1.5x the regular rate for ALL hours worked** (both regular and overtime), not just the overtime hours.

**Correct behavior:**
- Regular hours (up to 40): paid at `hourRate(rate)`
- Overtime hours (beyond 40): paid at `hourRate(rate) * 1.5`

**The fix:**
1. Split the calculation into regular pay (40 hours at base rate) and overtime pay (hours beyond 40 at 1.5× rate).
2. Sum both components and floor the result.
3. Handle the edge case where `hours <= 40` by returning just the regular pay (no overtime).

This correctly implements "pays the higher rate on all the hours worked" — meaning every hour is paid at the higher (overtime) rate, but only the hours beyond 40 qualify for that higher rate.