Employee Manager Role for only Active Employees

Hello Experts,

I have been trying to figure out a way to assign the Employee Manager role in OneIM to only those who have active persons listed as their direct report.  Currently if a person has an inactive employee listed it still assigns the employee manager role.  We have certain DLs that are dynamic an looks at this role for for provisioning.  I am am needing to make sure "Employee Manager " role is not assigned to those who have past inactive employees listed.  This would be very important in case we have a manager that gets demoted and has some employees listed as direct report but they are all inactive, Employee manager role should be stripped off.

I do see this code in the dynamic role for Employee manager but do not know how to tell to assign only if the direct reports are active.  We are currently using 8.0.1 version of OneIM

UID_Person in (select p.UID_PersonHead
from HelperHeadPerson p
where p.XOrigin > 0
union all
select o.UID_PersonHead
from HelperHeadOrg o
where o.XOrigin > 0
)
and isnull(IsInActive, 0) = 0

All your help is greatly appreciated.

Thank you,

JP