Merge Company changes note_foreignid in notes table for unrelated entities, notes are moved to a different record.

Hi all, having some issues with the Merge Company feature affecting Notes for other entities in Sage CRM and cannot find where to change it. We are currently using 2021 R2 and I've checked release notes for newer versions and didn't see any changes noted for Merge Company (other than some help topic text additions). Notes attached to an entity record are logged in the notes table as the note_foreignid = entityid (eg. comp_companyid, pers_personid or case_caseid, etc). I found when the Merge Company feature is used, it changes note_foreignid to the new companyid; however there's another column there for note_foreigntableid that differentiates which entity that note belongs to. Instead of only changing the note_foreignid if note_foreigntableid = 5, it changes ALL notes with that same note_foreignid even if it wasn't attached to the company records being merged.

Example of what happens:

Person 1: pers_personid = 3300, pers_companyid = 3378, note_foreignid = 3300, note foreigntableid = 13

Person 2: pers_personid = 3959, pers_companyid = 4056, note_foreignid = 3959, note foreigntableid = 13

Company 1: comp_companyid = 3300,  note_foreignid = 3300, note foreigntableid = 5

Company 2: comp_companyid = 3959,  note_foreignid = 3959, note foreigntableid = 5

After performing Merge Company and selecting to merge Company 1 (id = 3300) into Company 2 (id = 3959), now all notes with note_foreignid 3300 are changed to note_foreignid 3959. The two persons that had notes affected belonged to neither Company involved in the Merge (see pers_companyid value), but now all of the notes for Person 1's record is displayed on Person 2's notes tab. Same happens with notes for other entities if their note_foreignid happens to match the internal ID of the company being merged. The company notes themselves merged fine, as that was intended outcome of using merge.

Additional screenshots for better context and database output. Notice how all note_foreignid entries for 3300 was changed to 3959 after using Merge Company to move companyid 3300 into 3959, even though neither person these notes were associated with belong to either company involved in the merge.

Before merge:

After merge:

Any ideas? I think I've found all of the notes that were moved in our system, so mainly concerned on how to fix Merge Company to only change note_foreignid if note_foreigntableid = '5'.

Thanks,

Jason