That function is just to test.
Now that we know it works, we can do this:
add_filter( 'generate_block_element_display', function( $display, $element_id ) {
if ( 123 === $element_id ) {
if ( function_exists( 'bp_is_activity_component' ) && bp_is_activity_component() ) {
return true;
}
}
return $display;
}, 10, 2 );