Repeated masterpages use the same logic as any other repeated object - they have instance numbers.
To address the second instance you can use an expression like.
xfa.resolveNode("form1.masterpage[1].subform").presence = "hidden";
If you're not sure about the correct SOM expression you can use a small script for testing.
Put a textfield into the subform you want control.
Add this script into its calculate event.
this.rawValue = this.parent.somExpression;
If you preview the form in Designer you'll see the SOM expression of the text fields parent, which is the subform.
Copy it and put it into the script to hide the subform.