Hi,
The stock is restored when an order goes from a status under the "Invoice" column to a status under the "cancelled" column.
I suppose you might have changed the status of the order from another status than "confirmed". In that case, the change will be ignored.
For example, if you want to use the "shipped" status for your orders to indicate that an order has been sent to the user, but you want to be able to refund a user after an order is shipped, you want that shipped status to be abled under the "invoice" column.