If the department have the setting assignedmembersonly it looks like it'll reset the staff assigned but not if it's assigned to a team
https://github.com/osTicket/osTicket/blob/develop/include/class.ticket.php#L2021
You could replace the staffid=0 line with $this->unassign(); to do it properly and include team.