Interesting. Well, my best guess is that some other plugin is modifying the WP_Query
request we are making for attachments that have the current doc ID as the post_parent. (It’s not unusual for a plugin to use the pre_get_posts
hook to modify queries, but it can go wrong if done incorrectly.)
So the first test I’d do is deactivate all plugins other than BuddyPress and BuddyPress Docs and see if the behavior changes. Then reactivate the plugins one at a time until the problem resurfaces. Similarly, use a simple theme like TwentyTwenty for testing.
If the behavior still exists with only BP and BP Docs activated, then install Query Monitor (plugin) and look in the Queries list for a query for attachments. Let us know what it says.