Block discount codes when sale active
This approach below has one limitation: it only works with Product discount with type Amount off products. Unfortunately, there's no way in Shopify to do the same discount code restriction for other discount types.
To prevent discount codes from applying to products on sale follow these steps:
Create a new automated collection called "Eligible for discount codes" and select condition "Compare at price is empty" for it.
Open your discount codes and in "Applies to" section select collection "Eligible for discount codes".
This way discount codes won't apply to products on sale. Before creating automated collection you might need to create a task to reset Compare at price for products not on sale. This will remove some existing values from Compare at price field.