the filter function must be inside the action function, because if it isnt it is not recognize. So I think. At least with variables is like this.
add_action( 'woocommerce_before_checkout_form', 'add_checkout_error', 9 );
function add_checkout_error() {
wc_print_notice( __( 'An error message.', 'woocommerce' ), 'error' );
add_filter('woocommerce_order_button_html', 'remove_order_button_html' );
function remove_order_button_html( $button ) {
$button = '';
return $button;
}
}