Edit sub-assembly mate

I am trying to modify an angle mate from a sub-assembly using IAssemblyDoc::EditMate2. I did everything I found about it in the documentation : Select mate entities, select the mate feature then call EditMate2. However EditMate2 returns 0 (swAddMateError_ErrorUknown) and I can see that the mate was not modified. I tried calling IAssemblyDoc::EditAssembly on the sub-assembly component's assembly document before editing mate and also call EditMate2 on that assembly document but it also did not work. EditAssembly function does not even do anything. I expected it would be the equivalent of selecting the sub-assembly and clicking on "Edit Assembly".

If I open just the sub-assembly file, EditMate2 works very well.

What am I doing wrong?

SolidworksApi macros