Help - Grouping using formula creates issues

Hey,

I am creating a base to understand staff allocation over the various projects - 1 person goes to 1 project only until they are transferred. I had to assign people (names) to specific projects (as in their current projects). I have created a sheet called transfers where there is a FROM project and TO project. Over time, each person will have a number of transfers. So in the staff sheet we see the various TO sites where the person has been transferred to over time. Now to find the most recent transfer and hence their current project I used the solution from this answer: Find last entry

So it does some work in the background and basically finds the most recent entry for the person and shows that in the formula as text

The problem is the grouping. As you see the name name has gone into 3 groups Cummins Pithampur Since they are showing text from the same source, they are required to be in the same group. The logic beats me. Some help please.

Thanks
Vatsal.