Thank you for your reply John,
$post_id is now set, but it is always set to 0.
Possibly this is because I am using AJAX to load the form as described in this link.
https://www.advancedcustomfields.com/resources/acf_form/#ajax
I did some code tracing and here is the $_POST variable.
[
action => "acf/fields/post_object/query",
nonce => "c35b1d6bc1",
paged => "1",
s => "",
field_key => "field_588bcb6648c75"
]
Because post_id is not set it defaults to 0 as defined in acf_field_post_object->get_ajax_query()
Is this by design?
EDIT:
When I do this query from wp_admin, the post_id IS set.
In my example $post__not_in is an array. But this is not the issue.
The filter is called at the right time, but the $field and $post_id parameters are not set. It is not a subfield of a repeater field.