How to ignore a custom field in the order refund process in woocommerce

Solution:

I hit this issue as well. The problem is that woocommerce_admin_order_item_values is now getting called with both WC_Order_Refund as well as WC_Order_item. We now have to discern which type of object we’re getting when we receive it and handle accordingly. You can discern with this code.

if ($item->get_type() == 'shop_order_refund') {
    $item = new WC_Order_Refund($item_id);
}
else {
    $item = new WC_Order_Item_Product($item_id);
}

In your case I believe you need to change that first condition statement at the beginning of your code to something similar to.

switch ($item->get_type()) {
    case 'shop_order_refund':
        $val = $item->get_amount();
        break;
    case 'line_item':
    case 'shipping':
        $val = $item['total'] + $item['total_tax'];
        break;
    default:
        $val = ' ';
        break;
}