Array to string conversion on array_map

Look closely at $offices:

array (size=500)
  0 => 
    array (size=1)
      'id' => string '1382' (length=4)
  1 => 
    array (size=1)
      'id' => string '1330' (length=4)

That is not an array of IDs. It’s an array of arrays. $offices[0] is not '1382'. It’s an array. So implode() on $offices is trying to concatenate arrays, which is what’s causing your error.

The cause of the error is how you’ve used array_map. If you want to return this meta value for each post in an array, then you should only return the value, not a new array:

$offices = array_map(
    function($post) {
        return get_post_meta($post->ID, '_octopus_id', true);
    },
    $query->posts
);

Now $offices will be an array of IDs, which can be imploded.