When Merging organisation units, the target Organisation unit appears as top-level node in the tree

Description:

After performing a merge using the Organisation Unit Merge API, the target organisation unit (which was originally at a specific level within the organisation unit tree) ends up being displayed as a top-level organisation unit in the tree, despite being in its respective position before the merge.

Steps to Reproduce:

  1. Perform a merge by using superuser like system through the Organisation Unit Merge API with the following payload with a POST request to /api/organisationUnits/merge:
    {
      "sources": [
        "zsqxu7ZZRpO",
        "nurO6U9bOLi"
      ],
      "target": "PwoQgMJNWbR",
      "dataValueMergeStrategy": "LAST_UPDATED",
      "dataApprovalMergeStrategy": "LAST_UPDATED",
      "deleteSources": true
    }
    
  2. After the merge completes successfully (status 200 OK), observe the organisation unit tree.
  3. The target organisation unit (PwoQgMJNWbR) appears as a top-level unit, despite having been at a different level in the hierarchy before the merge.

Expected Behavior:

The target organisation unit (PwoQgMJNWbR) should retain its original position within the hierarchy after the merge and should not be displayed as a top-level unit.

Actual Behavior:

After the merge, the target organisation unit (PwoQgMJNWbR) incorrectly appears as a top-level organisation unit in the tree.

Environment Details:

  • DHIS2 Version: 2.41 to 2.39
  • API Endpoint Used: /api/organisationUnits/merge

Additional Information:

  • The merge completes successfully and the data from the source organisation units (zsqxu7ZZRpO, nurO6U9bOLi) is consolidated into the target (PwoQgMJNWbR).
  • The issue only affects the organisational hierarchy position of the target organisation unit.

2 Likes

@dhis2-platform can you kindly assist on how to take care of this issue?

Hi @ericchingalo

Does this happen even if all the OU sources are lower level hierarchy? Or is this happening only when the sources are higher level hierarchy than the target OU?

Either way, this is most probably a bug issue, would you like to create a Jira bug issue using your account in https://dhis2.atlassian.net/ and add the label CoP? Please share the link here so others can watch the ticket to receive notifications.

Thanks!