In additional settings/Order Management/Settings select for which statuses the COD should not be imported.
For selected statuses, the COD import will be disabled and the following error will be displayed:
This will prevent the import of COD for selected statuses, where the credit note is created, while the new invoice is missing.