When `$post` is null for [`get_post`](https://developer.wordpress.org/reference/functions/get_post/) it looks to `$GLOBALS['post']`.

There are several other checks in the [source](https://developer.wordpress.org/reference/functions/get_post/#source) so perhaps you should find out the value of the global variable when you're calling it or give it something besides and empty value.

What does [`get_the_id()`](https://developer.wordpress.org/reference/functions/get_the_id/) return vs. [`get_post(get_queried_object_id())`](https://developer.wordpress.org/reference/functions/get_queried_object_id/)? Or [`var_dump(get_queried_object())`](https://developer.wordpress.org/reference/functions/get_queried_object/)?