Hide on hold orders on My Account page in WooCommerce

Hide on hold orders on My Account page in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'woocommerce_my_account_my_orders_query', 'wc_exclude_status, 9999 );
 
function wc_exclude_status( $args ) {
   $statuses = wc_get_order_statuses();
   unset( $statuses['wc-on-hold'] ); // wc-completed, wc-processing, etc.
   $args['status'] = array_keys( $statuses );
   return $args;
}