Do the managers between CEO and a certain department have something in common? Maybe a keyword in their job titles? It's necessary whether find this common parameter that could be easily formalized or specify those managers in additional GET parameters individually.
If none works for you, then you could create a common parameter: just create a custom property in SharePoint user profiles and list in it all related departments for the managers which are between CEO and departments. Then check whether that property contains a department from a GET request with the includes() method.
For example you created a property "RelatedDepartments". The full list of available properties you can find here:
For this example, I use a list as a data source to save time (I don't have properly configured user profiles). The "RelatedDepartments" property is just a single line text column where I listed comma-separated departments:
Then the filtration rule will check whether a box has a certain department from request or the one is among related ones:
return itemData["Department"] == department || itemData["RelatedDepartments"].includes(department);
If you use SharePoint user profiles as a data source, then instead of list item id, you should use a part of user's account name to set a root node: