The approach that @punna0001 describes could work - If I’m understanding correctly:
pull the roles and break down the criteria
use the criteria from each role to perform a search: <roleCriteria> AND attributes.uid:<identity’s uid>
Repeat #2 for each role and return the results
Something else that may be useful - I just remembered that there is a community tool provided by @ethompson during Developer Days 2024 that previews role changes using a PowerShell script. You can find the post here: