Skip to main content

Funding Queue Remove-From-Queue Behavior

Summary

The funding queue’s single-item delete action should stop deleting fundingPlans rows. Instead, it should remove the contact from the default funding queue view by closing the linked processing submission and leaving all funding plan rows intact.

Problem

Today, the single-item delete action in the funding queue calls the funding-plan deletion path. That hard-deletes a fundingPlans row, which removes real plan data that operators may still need on the contact page. The intended behavior is narrower:
  • remove the contact from /admin/internal/funding-queue
  • preserve all funding plan line items
  • preserve access to those plans outside the queue

Goals

  • Keep existing fundingPlans documents unchanged when the single-item queue delete action is used.
  • Make the contact disappear from the default funding queue view immediately after the action succeeds.
  • Reuse existing queue status behavior where possible.
  • Update UI copy so the action describes removing from queue, not deleting plans.

Non-Goals

  • Changing the existing “Delete All Plans” action.
  • Adding a new schema field or archive concept.
  • Removing funding plans from the contact page or any non-queue views.

Chosen Approach

Use the linked processingSubmission as the queue-control record. When a user triggers the single-item delete action from the funding queue:
  • locate the queue item’s processingSubmission
  • set its status to closed_no_longer_processing
  • leave all linked fundingPlans rows untouched
This works with the existing queue behavior because the default queue filter already hides closed_no_longer_processing submissions.

Expected Product Behavior

For a queue item with exactly one displayed plan and an associated processing submission:
  • the action menu should offer a remove-from-queue action instead of “Delete Plan”
  • confirming the action should close the submission
  • the queue item should disappear from the default queue after mutation refresh
  • the funding plans should still exist on the contact record
For queue items without a processing submission:
  • the single-item remove action should not be shown, because there is no queue record to close safely
For the existing bulk destructive path:
  • “Delete All Plans” should keep its current behavior
  • it should remain the only action that actually deletes funding plans

Implementation Areas

Queue UI

Update components/funding-queue/FundingQueueTable.tsx so the single-item action:
  • is only available when item.processingSubmission exists
  • calls a submission-status mutation path instead of the plan delete path
  • uses queue-specific copy in the menu item, confirmation dialog, and toasts

Queue Hook

Update lib/hooks/useAdminFundingQueue.ts so the single-item action exposed to the funding queue:
  • accepts a processingSubmissionId instead of a planId
  • calls the existing submission status mutation or cancel helper
  • returns success and error data shaped for the existing queue UI

API / Convex

Prefer reusing existing submission-closing behavior in convex/processingSubmissions.ts rather than adding new queue-only state. The current deleteFundingPlanRow path in convex/fundingPlans.ts and app/api/funding-plans/delete/route.ts should no longer power the funding queue single-item action. Leave those paths untouched for now unless they are explicitly audited and repointed elsewhere.

Error Handling

  • If the queue item has no processingSubmission, the UI should not offer the remove action.
  • If the close-submission mutation fails, show a queue-specific error message and leave the queue item visible.
  • If the submission was already closed or missing, return a safe error message rather than deleting plans as a fallback.

Testing

  • Update or add a focused test covering the funding queue table copy/action wiring so the single-item action no longer references deleting a plan.
  • Add or update a test covering the hook/page wiring so the queue uses submission-closing behavior for single-item removal.
  • Preserve existing tests around “Delete All Plans” as the destructive path.

Open Decisions Resolved

  • Single-item queue removal should preserve fundingPlans: yes.
  • Queue removal should be implemented by hiding the queue record, not by deleting plan rows: yes.
  • Existing closed_no_longer_processing status should be reused: yes.