How to filter/limit/set permission for "Shared with" user list

Hi,

I have this requirement:
A user only can share document with other user which is in the same department.

I tried to limit the permission for department, it applied, the employee list only show employee which is in the same department. But the user list in “Shared with” is still showing all user. Is there any way to achieve this? Thanks.

this is my configuration for permision: