An order, a refund and a subscription are all shop_order-ish posts and are not the same class, so code type-hinting WC_Order breaks the first time a refund arrives.
$order = wc_get_order( $id );
if ( ! $order instanceof WC_Order ) {
return; // a refund, or nothing at all
}
if ( $order->get_type() === 'shop_order_refund' ) { /* ... */ }
wc_get_order() returns false for an id that is not an order, which is the other branch people omit — passing it a product id gives false rather than an exception, and the next line fails on a boolean. Checking the return before using it is unglamorous and it is the difference between a handled case and a fatal in a webhook.