diff --git a/ondeck/src/app/(dashboard)/manager/page.tsx b/ondeck/src/app/(dashboard)/manager/page.tsx index 1110f1c..87088d9 100644 --- a/ondeck/src/app/(dashboard)/manager/page.tsx +++ b/ondeck/src/app/(dashboard)/manager/page.tsx @@ -56,6 +56,7 @@ export default async function ManagerPage() { task: { clientId: { in: shapeClientIds }, status: { notIn: ['COMPLETED', 'CANCELLED', 'NA'] }, + NOT: { policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } } }, } }, select: { diff --git a/ondeck/src/app/api/dashboard/workload/route.ts b/ondeck/src/app/api/dashboard/workload/route.ts index 0098ca9..a8b0033 100644 --- a/ondeck/src/app/api/dashboard/workload/route.ts +++ b/ondeck/src/app/api/dashboard/workload/route.ts @@ -30,9 +30,12 @@ export async function GET(request: NextRequest) { }) const shapeClientIds = shapeClients.map((c) => c.id) - // Base task filter — scoped to Shape clients only + const DEAD_POLICY_STATUSES = ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] + + // Base task filter — scoped to Shape clients only, excluding dead policies const deptTaskWhere = { clientId: { in: shapeClientIds }, + NOT: { policy: { status: { in: DEAD_POLICY_STATUSES } } }, ...(departmentFilter ? { department: departmentFilter.toUpperCase() as DepartmentType } : {}), } diff --git a/ondeck/src/app/api/metrics/route.ts b/ondeck/src/app/api/metrics/route.ts index 86a55e1..a726658 100644 --- a/ondeck/src/app/api/metrics/route.ts +++ b/ondeck/src/app/api/metrics/route.ts @@ -60,7 +60,7 @@ export async function GET(request: NextRequest) { prisma.task.count(), prisma.task.groupBy({ by: ['status'], _count: { id: true } }), prisma.task.groupBy({ by: ['department'], _count: { id: true } }), - prisma.task.count({ where: { dueDate: { lt: now }, status: { notIn: ['COMPLETED', 'NA', 'CANCELLED'] } } }), + prisma.task.count({ where: { dueDate: { lt: now }, status: { notIn: ['COMPLETED', 'NA', 'CANCELLED'] }, NOT: { policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } } } } }), prisma.task.count({ where: { createdAt: { gte: todayStart } } }), prisma.task.count({ where: { completedAt: { gte: todayStart } } }), prisma.task.count({ where: { createdAt: { gte: weekAgo } } }), diff --git a/ondeck/src/app/api/tasks/route.ts b/ondeck/src/app/api/tasks/route.ts index e3a6403..be2f3b9 100644 --- a/ondeck/src/app/api/tasks/route.ts +++ b/ondeck/src/app/api/tasks/route.ts @@ -36,18 +36,24 @@ export async function GET(request: NextRequest) { policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } }, }, }, - // Exclude tasks on expired renewal groups + // Exclude tasks on expired renewal groups — but NEVER hide open tasks { OR: [ { policyGroupId: null }, { policyGroup: { renewalDate: { gte: cutoff } } }, + { status: { notIn: ['COMPLETED', 'CANCELLED', 'NA'] } }, ], }, - // Exclude old non-terminal tasks + // Keep ALL open tasks regardless of age; only show terminal tasks completed/closed recently { OR: [ - { dueDate: { gte: cutoff } }, - { status: { in: ['COMPLETED', 'CANCELLED', 'NA'] } }, + { status: { notIn: ['COMPLETED', 'CANCELLED', 'NA'] } }, + { + AND: [ + { status: { in: ['COMPLETED', 'CANCELLED', 'NA'] } }, + { completedAt: { gte: cutoff } }, + ], + }, ], }, ]