Retrieve the the users with tasks (remove the not) and then retrieve the tasks followed directly with a count of the tasklist retrieved. Then in a split decide if action is needed.
Example:
1) Get count of tasks unassigned (43)
2) Get count of users with no assignment (15)
3) Give each of those users 1 (43 - 15 = 28 left)
4) Get count of all users (25)
5) Iterate through each and use a counter
5a) For each user, assign (total / users) tasks + (total % users > 0 && total % users >= counter ? 1 : 0)
For example, 1st user will get (28 / 25) = 1 + ((28 % 25 = 3) > 0 && 3 >= 1) = 1 ==> 2
2nd user will get 1 + 1 => 2
3rd user will get 1 + 1 =>2
Rest get 1 + 0 => 1
There are other ways but figuring out how many to assign, I believe, is one of the easiest