WooCommerce Batch Numbers plugin has a setting to easily archive batches when they got expired. This job runs every day at midnight automatically, by searching into the database looking for rows that are already expired. When it founds something he changes the status to
archived preventing you to sell expired products.
To enable this setting go to Products > Batch Numbers > Options:
You could also choose to archive batches when reaching the offset window limit, for example 30 days before the actual expiry date: