Use bp_core_get_user_domain($user_id)
. This will give you the url part up to the username (with a slash at the end).
Try something like the following:
$user_id=bp_displayed_user_id();
$link=bp_core_get_user_domain($user_id)."profile/edit/group/8";