How do I apply RLS to a dataset based on managerial hierarchy in quicksight?

I have some idea on how to do this on Power BI with path and pathitem but i’m clueless on what to do with Quicksight. There are 9 levels of managers in my org. The dataset i’m trying to apply the RLS contains data for all the employees including managers. Only managers will be able to use the dashboard. But my org wants me to apply RLS in a way that each manager should only be able to see his own data as well as the employees(and lower level managers) under him.
As an added complexity, let’s just say ‘Rakesh’ is a manager. He maybe an l3 manager for three employees A,B,C. In addition to that he will also be a l4 manager for employee E. If there is no straightforward way for this, are there any workarounds? The org has around 15000 employess and around 300 managers. The 300 managers will get reader access to the dashboard. The screenshot is just sample data.

Hello @Shivam , welcome to the Quicksight Community!

Would you be willing to attempt this with some SQL? If so I believe the solution below could be helpful for this type of hierarchy.

Let me know if this helps!

Hello @Shivam !

Were you able to try the solution from the post in my comment?

It’s been a few days since we have heard from you but would still like to help you find the solution. If we do not hear from you in 3 days this post will be archived.