Union types and narrowingintermediate
A discriminated union makes impossible states impossible: one status field the compiler forces you to handle, instead of three booleans that can contradict each other.
Delivered orders never leave the "in progress" count. status is a string, so a typo in one comparison compiles happily. Make the typo impossible to write.
Invalid statuses and impossible comparisons are compile errors, and the count is right.
Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.
A discriminated union makes impossible states impossible: one status field the compiler forces you to handle, instead of three booleans that can contradict each other.