This issue was found in version 5.1.1 in Scholars Portal Dataverse. Apologies in advance if this has since been resolved!
When using the "merge user" API, the command appears to fail if the user has initiated a password reset.
The following messaging was in the server.log file, which suggests some data connected to the user is still in the passwordresetdata table and is preventing the merge:
Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "builtinuser" violates foreign key constraint "fk_passwordresetdata_builtinuser_id" on table "passwordresetdata"
Detail: Key (id)=(2232) is still referenced from table "passwordresetdata".
Error Code: 0