You should probably try this plugin first: http://buddydev.com/buddypress/blog-categories-for-groups-plugin/
Or you could take some code from it and try to implement that yourself. Start
with blog-categories-for-groups.php, and see the last few lines:
//for single post screen
function screen_group_blog_single_post(){
global $bp;
if(function_exists('bp_is_group')&&!bp_is_group())
return;
//do not catch the request for creating new post
if(bp_is_action_variable('create',0))
return;
$current_group=groups_get_current_group();
if(bcg_is_disabled($current_group->id))
return;
//if the group is private/hidden and user is not member, return
if(($current_group->status=='private'||$current_group->status=='hidden')&&(!is_user_logged_in()||!groups_is_user_member(bp_loggedin_user_id(), $current_group->id)))
return;//avoid prioivacy troubles
if (bp_is_groups_component() && bp_is_current_action(BCG_SLUG) &&!empty($bp->action_variables[0]) ){
$wpq=new WP_Query(bcg_get_query());
if($wpq->have_posts()){
//load template
bp_core_load_template( apply_filters( 'groups_template_group_blog_single_post', 'bcg/home' ) );
}
else
bp_core_add_message (__("Sorry, the post does not exists!","bcg"),"error");
}
}
See also: http://buddypress.org/support/topic/how-to-exclude-a-group-from-the-groups-loop/