Purge service checks sub-workflows before it deletes a workflow. If some of the sub-workflows is not yet ready to be purged it does not delete the workflow. Several unit tests also checks this, e. g. testPurgeWFWithSubWF1.
This check is recursive, it also checks sub-sub-workflows, sub-sub-sub-workflows....
The recursive check is buggy. Let's assume that we have a workflow (A) with a single sub-workflow (B), which also has a sub-sub-workflow (C). If A is ready to be purged, B is ready to be purged, and C is not ready to be purged then the current implementation correctly recognizes that C and B is not purgeable, but it purges A. Instead of this, it should also recognize that it's not possible to purge A.