The cht-conf move-contacts command is the recommended way to do this. Because of the CHT’s offline-first nature, moving contacts between users is not super convenient since it involves re-aligning the data that a user has access to, but the linked docs get into more specifics about the tradeoffs involved. (Also worth noting that the cht-user-management tool includes some functionality for helping to generate these move-contact commands.)
Also worth calling out that for your case of merging contacts from one user into another existing user, the move-contacts command makes the most sense. For different cases where perhaps you are replacing one user with another new user the create_new_user Sentinel transition provides some different functionality for doing this (even works offline).
First I just want to confirm that this is expected behavior as noted in the docs:
Offline users who have contacts removed from their visible hierarchy will not automatically see those contacts disappear.
Because of how the syncing algorithm works to determine which docs are visible to a user, currently when docs are moved so that a user no longer has access to them, in order for that user to not see those does anymore, you have to clear their cache and do a re-sync.
When testing on a browser, I use the “Clear site data” button on the Application tab of Chome’s DevTools:
After clearing the site data and logging back in as the user, the moved contacts should no longer be visible.
This, however, is unexpected. Here are some things we can check first:
Can you provide the exact move-contacts/upload-docs commands you ran? (with some notes about which contacts are associated with the relevant ids)
In the local json files for the moved contacts (by default these are in ./json_docs) can you confirm that the grandparent id has been updated in the file to point to the new CHW Area? The move-contacts command should have set the parent.parent._id value to match the id of the target CHW area (presumably this was the value you provided for --parent).
If the local json files were updated correctly, can you then confirm that the data in Couch was updated as expected. (e.g. use Fauxton to validate that the docs in Couch for these missing contacts match what is in the local json files)
The target user should not have to logout or clear any data. All they should need to do to see the moved contacts should be to sync successfully. Can you re-try the sync again and confirm the “All reports synced” message is shown? Also can you check the browser console logs when you do this for any suspicious errors?
Finally, if all else fails, can you try clearing the data for the target user and re-syncing everything? As I said before, I don’t know of any reason why this should make a difference, but for debugging it would be useful to know the result of a fresh sync…
Ah, yes! If things look as expected in the admin account, this should confirm that the update was successful on the server side. This means we can focus our efforts on understanding why the child contacts are not syncing to the new user.
The first thing to check is if you have replication_depth configured for the role(s) of the new user. Does the new user have the same or different roles as the original one? Can the new user see household members in other (existing) households?
The other main thing that would affect which docs get replicated to a user is the purging configuration. Do you have any purging configured for the new user’s role(s)? If so, it would be good to review that configuration and determine if it might be affecting these household members.
The fact that the household shows up for the new user, but not the members makes me think it is very likely to be one of these configuration options. Otherwise, there should not be anything that prevents the household members from being replicated…