feat(sp14): 5-lane Inbox UI with Payer-Rejected acknowledge action

Closes the gap between the SP10 backend (5 lanes) and the SP6
frontend (4 lanes). The Payer-Rejected lane (277CA STC A4/A6/A7)
is now rendered alongside Rejected/Candidates/Unmatched/Done,
with an Acknowledge bulk action that drops claims from the
working surface without erasing the original 277CA rejection
event (audit log stays intact, SP11).

Backend:
* Migration 0010: add payer_rejected_acknowledged_at +
  payer_rejected_acknowledged_actor columns + partial index.
* db.py: surface the two new columns on the Claim model.
* inbox_lanes.py: filter acknowledged claims out of the
  payer_rejected lane; expose the new fields on the row payload
  for forward-compat (e.g. a future 'Recently acknowledged' view).
* api.py:
  - POST /api/inbox/payer-rejected/acknowledge
    Bulk-acknowledge. Idempotent. Returns transitioned /
    already_acked / not_found / not_rejected counts so the UI
    can show '3 of 5 were already acknowledged' on a noop bulk.
    Writes a 'claim.payer_rejected_acknowledged' event to the
    SP11 hash-chained audit log.
  - GET /api/inbox/export.csv: accept 'payer_rejected' lane.
* test_acks.py: bump user_version assertion to 10.
* test_lane_filter_acknowledged.py: 4 tests for the lane filter
  and forward-compat row payload.
* test_payer_rejected_acknowledge.py: 6 tests for the endpoint
  (happy path, idempotency, no-op on non-rejected, missing
  ids, 400 on empty, audit-log wiring + chain integrity).

Frontend:
* lib/inbox-api.ts: add payer_rejected to InboxLanes, add
  acknowledgePayerRejected(), update exportInboxCsvUrl union.
* hooks/useInboxLanes.ts: add payer_rejected to initial state.
* hooks/useInboxLanes.test.ts: add payer_rejected to mocks.
* components/inbox/BulkBar.tsx: add 'payer_rejected' lane with
  Acknowledge action (no Resubmit, no Dismiss — payer-rejected
  is not eligible for either).
* components/inbox/BulkBar.test.tsx: add payer_rejected test.
* pages/Inbox.tsx: render the 5th lane, hook up onAcknowledge,
  include payer_rejected in the needEyes count.
* pages/Inbox.test.tsx: 3 new tests (5-lane render, need-eyes
  count, acknowledge action hits the right endpoint).
* components/inbox/InboxHeader.tsx: doc comment now explains
  why payer_rejected rolls up into need-eyes.

Pre-existing typecheck warnings in BulkBar.test.tsx / InboxRow
.test.tsx / Lane.tsx / download.test.ts are unchanged from
main — not touched here.

Test counts: backend 724 -> 734 (+10). Frontend 350 -> 354 (+4).
This commit is contained in:
Tyler
2026-06-21 00:13:47 -06:00
parent fdfbde35c6
commit 5c9365ec33
15 changed files with 704 additions and 18 deletions
+61 -4
View File
@@ -1,9 +1,15 @@
// ---------------------------------------------------------------------------
// Inbox page (sub-project 6).
// Inbox page (sub-project 6, SP14).
//
// Full-bleed dark working surface for the four-lane triage workflow.
// Full-bleed dark working surface for the five-lane triage workflow.
// Wires useInboxLanes + Lane + InboxHeader + BulkBar. Bulk actions call
// the inbox API client and refetch on completion.
//
// SP14: added the `payer_rejected` lane (277CA STC A4/A6/A7) and the
// Acknowledge bulk action. The Payer-Rejected lane sits between
// `rejected` (envelope) and `candidates` (recon opportunities) so the
// operator's eye flow is: envelope problems → payer problems →
// auto-recon opportunities → claims still in flight → done today.
// ---------------------------------------------------------------------------
import { useState } from "react";
@@ -16,10 +22,16 @@ import {
dismissCandidates,
resubmitRejected,
resubmitRejectedWithDownload,
acknowledgePayerRejected,
} from "@/lib/inbox-api";
import { downloadBlob } from "@/lib/download";
type LaneKey = "rejected" | "candidates" | "unmatched" | "done_today";
type LaneKey =
| "rejected"
| "payer_rejected"
| "candidates"
| "unmatched"
| "done_today";
function rowKey(row: LaneRow): string {
return row.kind === "remit" ? (row as { payer_claim_control_number: string }).payer_claim_control_number : row.id;
@@ -29,6 +41,7 @@ export default function Inbox() {
const { lanes, loading, error, refetch } = useInboxLanes();
const [selected, setSelected] = useState<Record<LaneKey, string[]>>({
rejected: [],
payer_rejected: [],
candidates: [],
unmatched: [],
done_today: [],
@@ -127,6 +140,18 @@ export default function Inbox() {
}
}
async function onAcknowledge() {
// SP14: drop selected payer-rejected claims from the working
// surface. The backend persists an `acknowledged_at` timestamp;
// the original 277CA rejection (status code, reason, source 277CA
// id) stays intact for the SP11 audit log.
const ids = selected.payer_rejected;
if (ids.length === 0) return;
await acknowledgePayerRejected(ids);
setSelected((prev) => ({ ...prev, payer_rejected: [] }));
await refetch();
}
function onExport(lane: LaneKey) {
if (selected[lane].length === 0) return;
window.open(exportInboxCsvUrl(lane), "_blank");
@@ -162,8 +187,15 @@ export default function Inbox() {
);
}
// SP14: payer_rejected is also actionable — a 277CA rejection that
// needs operator follow-up. Without it, payer-side rejections would
// hide behind the 999 envelope "rejected" lane and the operator
// could miss a high-value denial.
const needEyes =
lanes.rejected.length + lanes.candidates.length + lanes.unmatched.length;
lanes.rejected.length +
lanes.payer_rejected.length +
lanes.candidates.length +
lanes.unmatched.length;
return (
<div
@@ -179,6 +211,19 @@ export default function Inbox() {
onRowClick={() => {}}
onSelectionChange={(ids) => setLaneSelected("rejected", ids)}
/>
{/*
SP14: payer-rejected (277CA STC A4/A6/A7). Distinct accent
from the 999 envelope rejected lane — the operator's eye
flow is: 999 problems → payer problems → reconciliation
opportunities → claims still in flight → done today.
*/}
<Lane
name="PAYER REJECTED"
accent="oxblood"
rows={lanes.payer_rejected}
onRowClick={() => {}}
onSelectionChange={(ids) => setLaneSelected("payer_rejected", ids)}
/>
<Lane
name="CANDIDATES"
accent="amber"
@@ -207,13 +252,23 @@ export default function Inbox() {
lane="rejected"
count={selected.rejected.length}
onResubmit={onResubmit}
onAcknowledge={() => {}}
onDismiss={() => {}}
onExport={() => onExport("rejected")}
/>
<BulkBar
lane="payer_rejected"
count={selected.payer_rejected.length}
onResubmit={() => {}}
onAcknowledge={onAcknowledge}
onDismiss={() => {}}
onExport={() => onExport("payer_rejected")}
/>
<BulkBar
lane="candidates"
count={selected.candidates.length}
onResubmit={() => {}}
onAcknowledge={() => {}}
onDismiss={onDismiss}
onExport={() => onExport("candidates")}
/>
@@ -221,6 +276,7 @@ export default function Inbox() {
lane="unmatched"
count={selected.unmatched.length}
onResubmit={() => {}}
onAcknowledge={() => {}}
onDismiss={() => {}}
onExport={() => onExport("unmatched")}
/>
@@ -228,6 +284,7 @@ export default function Inbox() {
lane="done_today"
count={selected.done_today.length}
onResubmit={() => {}}
onAcknowledge={() => {}}
onDismiss={() => {}}
onExport={() => onExport("done_today")}
/>