Server script issue when creating a new employee

I have written a script for the employee form for the reports_to field which automatically creates the user permissions of the employee added to the field. I have written 2 scripts for before and after save so that when an existing employee’s reports_to changes it deletes the previous permissions and creates new permissions according to the changes in the field
The issue I am facing is in the before save script that when I create a new employee it says employee already exists


This is the code snippet for the before save scripts,