Conditional statements based on custom meta value in category archives

Well guys, I ended up doing something like this which I am certain isn’t the best way. Seems like a lot of work just to get to the nugget. Could’ve sworn I’ve seen a simpler way but it’s escaped me all day. This is ugly and probably highly inefficient but it works. Please do let me know or point me to a better solution if you know one.

global $posts, $post;
if( is_front_page() || is_archive() ) {     
$hide_pages = array();
        foreach ($posts as $post) {
            $hide_pages[] = ( empty( get_post_meta( $post->ID, '_prefix_hide_page', true ) ) ) ? '0' : get_post_meta( $post->ID, '_prefix_hide_page', true ) ;          
        }
        if( in_array('1', $hide_pages, true) ) {
            $hide_page="1";
        }
    }