From 38365e97b560fde41cf7a869f03db6dc5c46545a Mon Sep 17 00:00:00 2001 From: lorentz Date: Fri, 17 Jul 2026 15:35:45 +0000 Subject: [PATCH] fix(clients): Show Completed toggle did nothing for tasks older than 7 days MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default task fetch (/api/clients/[id]/tasks) already excludes completed/cancelled/NA tasks older than a 7-day cutoff server-side. The "Show Completed" button only filtered the in-memory task list, so if all completed tasks were older than a week, toggling it revealed nothing — they were never fetched. Wire the toggle to re-fetch with archived=true (bypasses the cutoff) when turning it on, and revert to the default filtered fetch when turning it back off, so it doesn't leak dead-policy tasks into the non-completed view. --- ondeck/src/components/clients/client-detail.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ondeck/src/components/clients/client-detail.tsx b/ondeck/src/components/clients/client-detail.tsx index 4459dce..df1431a 100644 --- a/ondeck/src/components/clients/client-detail.tsx +++ b/ondeck/src/components/clients/client-detail.tsx @@ -112,6 +112,16 @@ export function ClientDetail({ client, designations, policyGroups = [], allPolic refreshTasks(next) } + const handleToggleCompleted = () => { + const next = !showCompleted + setShowCompleted(next) + // The default (non-archived) task fetch only includes completed/cancelled/NA tasks + // from the last 7 days — anything older needs the archived fetch to actually load. + // Revert to the filtered fetch when turning it back off (unless Show Archived is + // separately on) so dead-policy tasks pulled in by the archived fetch don't leak in. + if (!showArchivedTasks) refreshTasks(next) + } + // Assignments state const [allUsers, setAllUsers] = useState([]) const [claimsUsers, setClaimsUsers] = useState([]) @@ -647,7 +657,7 @@ export function ClientDetail({ client, designations, policyGroups = [], allPolic {/* Show completed toggle */}