How can write logic in REST API if current user login is from department XX-YYZ-AB or ZZ-YYZ and I have another list with list of people with different departments, so how shall I exclude users in my REST call so if I am from XX-YYZ-AB shall exclude all users who fall under XX-YY same goes for if my login department is ZZ-YYZ it exclude all user in my REST call who falls under ZZ-YY.
for ex
Login User Dept AA-XXV
And other users department
AA-XXV
AA-XXV-GG
AA-XX
AA
So it should only show AA after filter in rest api is it possible other should exclude ?