Tenancies List Now Defaults to 'Needs Attention First'
Tenancies List: 'Needs Attention First' Default Sort
Version introduced: v0.1.233
Overview
The tenancies list now defaults to 'Needs Attention First' ordering (risk_desc). Instead of surfacing the most recently created tenancy at the top, the list leads with the tenancies that pose the greatest risk or have the most pressing deadlines.
This brings the tenancies list into alignment with the dashboard work queue and the Properties page, both of which already apply urgency-aware ordering.
Why the previous default was a problem
The old default — 'Newest First' — ordered tenancies purely by creation date. This meant:
- A tenancy ending in 2 days with no check-out report could be buried halfway down the list.
- A tenancy created yesterday with no upcoming obligations would appear at the top.
- Users had to manually re-sort or rely solely on the dashboard work queue to find urgent items.
How 'Needs Attention First' works
The sort applies a four-tier priority to every tenancy:
| Priority | Condition | Why it matters |
|---|---|---|
| 1 (highest) | Ending within 7 days and no check-out report filed | Imminent deadline with missing evidence |
| 2 | Tenancy has ended and deposit has not been released | Overdue closure, potential compliance issue |
| 3 | Deposit is unprotected | Legal compliance risk |
| 4 (lowest) | All other tenancies, newest first | Standard fallback ordering |
Within each tier, tenancies are ordered newest first as a tie-breaker.
What stays the same
- 'Newest First' and 'Deposit (High–Low)' sort options are still available in the sort dropdown.
- Any workflow or deep-link that specifies an explicit sort parameter continues to behave as before.
- No tenancy data is hidden or removed — only the default ordering has changed.
Relationship to other urgency surfaces
| Surface | Urgency-aware? |
|---|---|
| Dashboard work queue | ✅ Yes (pre-existing) |
| Properties page | ✅ Yes — risk_desc sort (pre-existing) |
| Tenancies list | ✅ Yes — risk_desc sort (new in v0.1.233) |
The underlying sort logic in the Tenancies router is modelled directly on the risk_desc implementation in src/lib/routers/properties.ts, ensuring consistent behaviour across both list views.
For developers
The risk_desc sort is implemented in the Tenancies router's listTenancies query using an ORDER BY clause with four weighted conditions:
ORDER BY
-- 1. Ending within 7 days with no checkout report
CASE WHEN end_date <= NOW() + INTERVAL '7 days'
AND checkout_report_id IS NULL
THEN 0 ELSE 1 END,
-- 2. Ended with no deposit release
CASE WHEN end_date < NOW()
AND deposit_released_at IS NULL
THEN 0 ELSE 1 END,
-- 3. Unprotected deposit
CASE WHEN deposit_protected = false
THEN 0 ELSE 1 END,
-- 4. Newest first (tie-breaker)
created_at DESC
The SORT_OPTIONS constant in tenancies-list.tsx has been updated to include { value: 'risk_desc', label: 'Needs attention first' } as the first entry, making it the default selection on page load.