I see that when enabling the option "Change stock on 'completed' status", only orders with "completed" status will have the stocks affected. But when I use "refund" action from the dashboard, it will still not change the stocks properly.
After debugging further, I see that in your source code that it will check if the current order status is "completed" under the function "maybe_allow_restock_refunded_items" (where apply_filter is done for "woocommerce_can_restock_refunded_items"). But the problem here is that when this filter is called to trigger a re-stock, the order status has already changed to "refunded" causing the function to not allow a re-stock to happen. Is this really the intended implementation? Why so?