I have the same problem on my website also with bbPress 2.6.4 and BuddyPress 5.1.2. @robin-w Thanks for the suggested fix. Unfortunately, inserting your code into my child theme’s functions.php did not fix the problem for me.
… well I think I found a solution: set the forum visibility to “hidden”. I wish this would have been documented somewhere (maybe it is, but I couldn’t find anything about “private” vs “hidden” forums in the documentation).
So if anyone else runs into this: if you have “private” or “hidden” groups, in either case most likely you want to set the group forum to “hidden”, as far as I can tell.