WP_Http response throws “Cannot use object of type WP_Error as array”

Your logic for your updated if statement is wrong.

if( !is_wp_error($response) && $response['response']['code'] != 200 )

Here you are saying; if NOT wp_error AND response code NOT 200 return false. So your not actually catching the WP_Error

I believe what you are after is something like:

if ( is_wp_error($response) || $response['response']['code'] != 200 ) return false;

IS wp_error OR code NOT 200

error code: 523