In my use case, I have a user task, Let's call it User Task 1. There's a button called "Re-assign". If you press this button, it takes you to User Task 2. If you don't, the workflow changes, but that's fine. When you do get to User Task 2, you select a new user to re-assign that task. When you press Submit, a Groovy script is called. In that script, the current user is being removed from the role that can execute User Task 1, and the new user is added to that role. But as soon as the script is executed, current user again sees User Task 1 and the new user doesn't.
It seems like a concurrency issue, perhaps? Because when the current user sees User Task 1 again, and presses "Re-assign" again, the current user doesn't see the User Task 2, the new user now sees User Task 2.
Flow problem: New user should have seen User Task 1, and current user shouldn't have seen User Task 1 for the second time.
I hope I got my point across, thank you for your help!
Not quite. I'm still not understanding the bpmn model that you're trying to implement here. Are you implementing a 'Task Reassignment' workflow? Instead of listing out the steps of what you are doing, take a step back and explain the higher goal of what you're trying to achieve. It is important to understand the goals and get the process modelling right before we can talk about deeper technical pieces.
You stated the problem is that
New user should have seen User Task 1, and current user shouldn't have seen User Task 1 for the second time.
This is not a good problem statement unless you can attach a unit test that we can run and see the issue. Without a unit test, it's difficult for anyone in this forum to help you.
Please spend time to write up a unit test that demonstrates your issue so people here can help you resolve it.