Housing shall qualify for affordable housing for purposes of this subchapter only if-
(1) each dwelling unit in the housing-
(A) in the case of rental housing, is made available for occupancy only by a family that is a low-income family at the time of the initial occupancy of that family of that unit; and
(B) in the case of housing for homeownership, is made available for purchase only by a family that is a low-income family at the time of purchase; and
(2) each dwelling unit in the housing will remain affordable, according to binding commitments satisfactory to the Secretary, for-
(A) the remaining useful life of the property (as determined by the Secretary) without regard to the term of the mortgage or to transfer of ownership; or
(B) such other period as the Secretary determines is the longest feasible period of time consistent with sound economics and the purposes of this subchapter, except upon a foreclosure by a lender (or upon other transfer in lieu of foreclosure) if that action-
(i) recognizes any contractual or legal rights of any public agency, nonprofit sponsor, or other person or entity to take an action that would-
(I) avoid termination of low-income affordability, in the case of foreclosure; or
(II) transfer ownership in lieu of foreclosure; and
(ii) is not for the purpose of avoiding low-income affordability restrictions, as determined by the Secretary.
Notwithstanding subsection (a), housing assistance pursuant to section 4228(a)(2)(B) of this title shall be considered affordable housing for purposes of this subchapter.
(