Hi,
That should be the case by default.
However, the system bases itself on the configuration of the order statuses in the System>Order statuses menu.
There, you have the "cancelled" column, where you can select the statuses that HikaShop will consider to restock products when an order's status changes to one of them. By default, both "cancelled" and "refunded" are enabled in them.
Also, you have the "invoice" column, where you have "confirmed" and "shipped" selected by default. That's the statuses HikaShop will consider that the products' stock is reserved.
So normally, the status has to change from one of the statuses in that invoice column to one of the statuses in that "cancelled" column.
So, in short, I would recommend first checking your order statuses configuration in System>Order statuses.