You have done a fine job of analyzing this complex scenario.The transaction does appear to be a refinance of a multi-family dwelling.But the 20 units leased to the non-profit may be transitory units. “Transitory” indicates the borrower lives here for a while before returning the their regular residence. Is that the case with these units? Once the residents get “back on their feet” do they return to their homes?
With more information you should be able to determine if the units are transitory. If they are, with 20 of 22 units used in a transitory manner, it should be easy to argue primary purpose.