Wire BulkApprovalBar selection state management
epic-expense-approval-workflow-bulk-and-action-task-005 — Connect BulkApprovalBar to the coordinator review queue selection state using Riverpod or BLoC. Bar must reactively show/hide based on whether any claims are selected, update the count badge on selection change, and disable action buttons during in-progress batch processing to prevent duplicate submissions.
Acceptance Criteria
Technical Requirements
Execution Context
Tier 1 - 540 tasks
Can start after Tier 0 completes
Implementation Notes
Use Riverpod's StateNotifierProvider.autoDispose to ensure state is cleaned up when the coordinator queue screen is popped. Define a ClaimSelectionState class with selectedClaimIds (Set
This keeps the state small and avoids stale data issues if the claim list refreshes during processing.
Testing Requirements
Unit tests on StateNotifier/BLoC: (1) toggle adds then removes same ID correctly, (2) selectAll adds all provided IDs, (3) clearSelection empties the set, (4) setProcessing(true) sets isBulkProcessing and (5) setProcessing(false) clears it, (6) onBatchComplete(result) clears all IDs on full success, (7) onBatchComplete(result) retains failed IDs on partial failure. Widget integration tests: (1) tap a claim row and verify BulkApprovalBar appears with count 1, (2) tap same row again and verify bar disappears, (3) verify checkboxes disabled during isProcessing=true. Use flutter_test with ProviderContainer for state tests.
If a bulk approval batch partially fails (some claims approved, some failed), the UI must communicate which specific claims failed without overwhelming the coordinator. A poorly designed error display could cause coordinators to re-approve already-approved claims or miss claims that still need attention.
Mitigation & Contingency
Mitigation: Design the BulkApprovalResult display to show a clear summary (e.g., '14 approved, 2 failed') with a collapsible list of failed claims including their IDs and submitter names. Failed claims should remain selected in the queue so the coordinator can retry them individually.
Contingency: If the summary UI proves insufficient, add a dedicated 'bulk action history' sheet showing the last bulk operation result, accessible from the queue screen header.
If the app is backgrounded or the network drops while the coordinator has the ApprovalActionSheet open mid-decision, the typed comment could be lost and the transition state could be ambiguous, potentially causing a coordinator to believe they approved a claim that was never submitted.
Mitigation & Contingency
Mitigation: Persist the in-progress action sheet state (selected action + comment text) to a local draft store keyed on claim ID. On sheet re-open for the same claim, restore the draft. After confirmed submission, verify the resulting claim status from the server before dismissing the sheet.
Contingency: On network error during submission, display a persistent retry banner within the sheet rather than dismissing it, so the coordinator can resubmit without re-entering their comment.