I found the answer to this question with support from the members from the BuddyPress forum. The function that I needed was xprofile_get_field_data().
Here my code:
<?php $hidden_fields = bp_xprofile_get_hidden_fields_for_user(); ?>
<?php if(xprofile_get_field_data('field_name') && !in_array(xprofile_get_field_id_from_name('field_name'), $hidden_fields)) : ?>
<p><?php echo xprofile_get_field_data ('field_name'); ?></p>
<?php endif; ?>
solved BuddyPress Xprofile check if user can view field [closed]