From cb740c25216e347bec444e5dc386d18d63f4f567 Mon Sep 17 00:00:00 2001 From: renee-png Date: Sun, 7 Jun 2026 13:21:08 -0400 Subject: [PATCH] Bill approvals: fix approver column always showing "None" The list loaded all bills (~1,150) then fetched approvers with .in("bill_id", [all ids]); that request URL exceeds server limits and fails silently, so approvalsByBill was always empty. Fetch the small bill_approvals table directly (RLS scopes per role) and group locally. Co-Authored-By: Claude Opus 4.8 --- src/pages/BillApprovalsPage.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/BillApprovalsPage.tsx b/src/pages/BillApprovalsPage.tsx index 5217dc5..f3e5c81 100644 --- a/src/pages/BillApprovalsPage.tsx +++ b/src/pages/BillApprovalsPage.tsx @@ -216,15 +216,21 @@ export default function BillApprovalsPage({ boardAssociationIds }: { boardAssoci setAccounts(coaRes.data || []); setVendors(vRes.data || []); - // Fetch approvals for all bills + // Fetch approvals for all bills. + // NOTE: do NOT filter with .in("bill_id", billIds) — with 1k+ bills the + // request URL exceeds server limits and silently fails, leaving every row + // showing no approvers. The bill_approvals table is small and RLS already + // scopes rows per role, so fetch it directly and group locally. if (billsList.length > 0) { - const billIds = billsList.map((b: any) => b.id); - const { data: approvals } = await supabase + const billIdSet = new Set(billsList.map((b: any) => b.id)); + const { data: approvals, error: approvalsErr } = await supabase .from("bill_approvals") .select("id, bill_id, approver_name, status") - .in("bill_id", billIds); + .not("bill_id", "is", null); + if (approvalsErr) console.error("Failed to load approvals:", approvalsErr); const grouped: Record = {}; (approvals || []).forEach((a: any) => { + if (!a.bill_id || !billIdSet.has(a.bill_id)) return; if (!grouped[a.bill_id]) grouped[a.bill_id] = []; grouped[a.bill_id].push(a); });