---
title: "A user sees employees outside their department, or an unexpected \"Reports To\""
space: "Framework"
url: "https://docs.frappe.io/framework/help/a-user-sees-employees-outside-their-department-or-an-unexpected-reports-to"
updated: "2026-11-17"
---

If you restrict what an Employee-role user can see with a User Permission, they can end up seeing employee records that have nothing to do with them — in the **Permitted Documents for User** report, in their own Employee list, or as unexpected names and counts in the **Organizational Chart**. This happens for two different reasons, and they need two different fixes.

## **Why this happens**

**Most often: the User Permission is on Company, not on the Employee.** The Employee role by itself does not restrict users by department — anyone with it can read every Employee of their company. If the only User Permission on that user is for **Company**, they see every employee of that company, across every department. This is expected behaviour, not a bug, even if it looks like a department mix-up.

**Less often, but confusing when it happens: the Employee hierarchy (the "tree") is out of sync with Reports To.** Employee is a tree doctype — Frappe builds a hierarchy from the **Reports To** field, the same one the Organizational Chart uses. If a user's only User Permission is on their own **Employee** record (the normal result of the "Create User Permission" checkbox), Frappe automatically extends that permission to everyone below them in that hierarchy, so a manager can see their team without a separate permission for each person.

To do this quickly, Frappe does not walk the Reports To chain every time. It keeps a separate index on each Employee record (internally called `lft`/`rgt`) that marks its position in the hierarchy, and permission checks compare that index instead. Normally the index updates automatically whenever you save an Employee with a changed **Reports To**. But some changes skip that step — a Data Import that sets Reports To in bulk, a direct data fix, or a merged/renamed employee — and the index is left pointing at the old structure, even though Reports To on the record itself is correct. A user permission then expands against that stale index and returns the wrong set of employees: people who used to be under this employee, or never were, instead of their actual team. The Organizational Chart's connection counts and expand/collapse are built from the same index, which is usually what reads as "Reports To shows someone they don't actually report to" — Reports To on the record is fine; what is wrong is the chart's and the permission's idea of the hierarchy.

## **How to tell which one you have**

1. Open **User Permission** and filter by the affected **User**.
2. Check the **Allow** column.
  - If it says **Company** (or any doctype other than Employee): this is the expected, by-design behaviour above. Go to [Narrow it to one employee's team](https://claude.ai/epitaxy/local_92f3cace-96c6-4aaf-ad11-f42c79a24154#narrow-it-to-one-employees-team) below.
  - If it says **Employee**: continue to the next section — this is the stale-hierarchy case, and the fix is to rebuild the Employee tree.

## **Rebuild the Employee tree**

1. Go to the **Employee** list and switch to **Tree View** (`/app/employee/view/tree`).
2. Select the affected **Company** from the filter at the top, if you have more than one.
3. Click the **···** menu at the top right.
4. Select **Rebuild Tree**.
  ![](/files/pasted-image-7c7fiidp.webp)

Frappe walks every Employee from the top down, following each one's **Reports To** field, and rewrites the internal hierarchy index to match. It does not change any Employee's Reports To, department, or any other field — only the index permission checks and the Organizational Chart use internally. This needs the **System Manager** role.

Re-open the **Permitted Documents for User** report for the affected user afterward and confirm the list now matches their real team.

## **How to prevent it**

- After any bulk change to Reports To that does not go through opening and saving each Employee one at a time — a Data Import, a script, a direct data fix — run **Rebuild Tree** on the Employee list as a routine last step.
- After merging or renaming an Employee record, check the Organizational Chart and the Permitted Documents for User report for anyone whose permission depends on that employee's position in the hierarchy.

## **Narrow it to one employee's team**

If the real cause is a Company-level permission and you want the user to see only their own record, or only their own team, replace it with a permission on **Employee** instead:

1. Open the user's own **Employee** record.
2. Tick **Create User Permission**, then save. This creates a User Permission for **Employee = this record**, which (per the mechanism above) also covers everyone reporting to them.
3. If you want it to cover only that one record, with nobody reporting to them included, open the new User Permission and tick **Hide Descendants**.

There is no built-in setting for "this department only" visibility that is not also based on Reports To — that needs a custom Permission Query Condition script, which is outside what support can set up on your behalf.

## **If this does not fix it**

If the list is still wrong after a rebuild and the permission really is on Employee, check the **Reports To** field on a few of the unexpected employees directly — if it genuinely points to the wrong manager, that is normal record data to correct on the Employee form, unrelated to the tree index. If you are still unsure which of the two causes applies, raise a support ticket with the affected user's name, the User Permission list for that user, and a screenshot of the Permitted Documents for User report.

## **Related**

- [User Permission based on Hierarchy](https://docs.frappe.io/hr/user-permission-based-on-hierarchy)
- [User Permissions in ERPNext](https://docs.frappe.io/erpnext/user-permissions)
- [Organizational Chart](https://docs.frappe.io/hr/organizational-chart)
- [Rebuild the Chart of Accounts Tree](https://docs.frappe.io/erpnext/rebuild-tree)