So it depends on the user A and B’s capture scope at the very least.
So lets assume User X has capture scope access to org unit A. User X is therefore able to register X into orgunit A and enroll X into a program P in orgUnit A. In this case, since the enrollment is done, as of now the owner OrgUnit for TEI- Program P combination is orgUnitA.
Now comes the referral part. If the User X refers the TE to orgUnitB (Move permanently), then the ownership is not transferred to orgUnit B for the TEI- Program P combination.
If User Y has capture scope access to orgunit B and if he searches for TEIs that are enrolled in program P, the TE will be shown in his list.
This is the basic flow of referral. Now there are multiple variations here. If the referral is done as “One Time”. The event will be scheduled for orgUnitB, but the ownership will not be transferred to orgUnitB. User Y will ideally be able to search for the tei (without the context of the program) and find the TE in his search scope.
There is also various program configuration which restricts whether the ownership should be considered across the capture scope or the search scope. Program AccessLevel of (OPEN or AUDITED) gives more access to the users. The owning org unit is compared against the user’s Search scope of the user and not just the capture scope. Which means that the rules are less strict or less restricted for such program access level. If the program AccessLevel is either (PROTECTED or CLOSED), then the owning org unit is compared against the user’s capture scope.
Let me know if any of these are confusing