I avoid creating custom php over-rides as it will need checks/updates when Civi is upgraded. I added the same thing using the extension. Below is an example how I achieved
function extensionname_civicrm_alterReportVar($varType, &$var, &$object) {
if ('columns' == $varType && get_class($object) == 'CRM_Report_Form_Activity') {
$permCustomGroupIds = [];
$_customGroupExtends = $object->getVar('_customGroupExtends');
$_customGroupExtends = array_merge($_customGroupExtends, [
'Contact',
'Individual',
'Household',
'Organization',
'Case',
]);
if (!CRM_Core_Permission::check('access all custom data')) {
$allGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id');
$permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL);
// do not allow custom data for reports if user doesn't have
// permission to access custom data.
if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) {
$_customGroupExtends = [];
}
}
$object->setVar('_customGroupExtends', $_customGroupExtends);
$object->addCustomDataToColumns(TRUE, $permCustomGroupIds);
}
}