Unexpected User Assignment After Org Unit Merge via API

Hi DHIS2 Community,

I’m currently working with the DHIS2 API to merge organisation units, and I’ve encountered an unexpected behavior I hope someone can help me understand or resolve.

I’m using the /organisationUnits/merge API endpoint to merge two org units. The merge operation itself completes successfully, and the new (merged) org unit is created as expected.

{
        "sources": [
            "d3hu33vHbpo",
            "xQYr5E57h8K"            
        ],
        "target": "xL5orAzMbkI",
        "dataValueMergeStrategy": "LAST_UPDATED",
        "dataApprovalMergeStrategy": "LAST_UPDATED",
        "deleteSources": true
    }

However, I’ve observed that after the merge, the newly created org unit gets automatically assigned to some users, even though I haven’t explicitly updated any user assignments. This results in an incorrect organisation unit tree for those users, as seen in the user management UI.

:pushpin: Issue Summary:

  • The newly created org unit inherits users unexpectedly.
  • This leads to a misaligned org unit hierarchy for affected users, potentially impacting data access and workflows.
  • I’m still investigating the exact cause, but it seems like the merge process may be updating user assignments implicitly.

:hammer_and_wrench: Current Status:

  • I’ve verified that I didn’t manually update the user assignments post-merge.
  • This behavior is reproducible across multiple test cases.

DHIS2 Version 2.40.7

Has anyone experienced a similar issue? Could this be a known bug or expected behavior of the API? I would greatly appreciate any insights or suggested workarounds.

Thanks in advance!

2 Likes

Hi @Kenyuri

I have a question about the affected users assigned to the newly imported OUs. Were they assigned to the sources OUs? Is there anything that could connect these users to the newly imported OU?

Are they assigned to a parent of the new OUs? For example, User 1 is assigned OU A and the new OU B is a child of OU A, so User 1 is assigned OU B, or is it possible that these assignments are completely random?

Is there anything that is similar about these assigned users that’s different from the users that are not getting assigned? For example, they’re all included in a user group or have the same roles?

Prior to the merge, the affected users were not assigned to the original source organizational units (OUs). After the merge, these users are now assigned to the new organizational unit where the data was transferred. I have not identified any correlation between the affected users and the newly imported OU.

For your information, this issue did not occur in version 2.39