STALE CLOSURE BUG ON STATUS TOGGLE
Toggling an invoice from Paid back to Pending would silently revert because the context function closed over a stale copy of the invoices array.
I switched all state mutations to the functional updater pattern — setInvoices(prev => ...) — so React always passes the latest state into every mutation, eliminating the stale closure entirely.



