; and (2) by adding at the end the following new subparagraph: (C) If an individual is entitled for any month to a widow's or widower's insurance benefit and is also entitled to an old-age or disability insurance benefit for such month that is greater than such widow's or widower's insurance benefit, the reduction described in subparagraph (A), with respect to such widow's or widower's insurance benefit, shall be carried out by substituting an amount equal to the primary insurance amount of the deceased individual referred to in subsection (e)(1) or (f)(1) (as determined for purposes of subsection (e)(2)(A)(i) or (f)(2)(A)(i)) for the amount equal to the old-age or disability insurance benefit of the individual entitled to the widow's or widower's insurance benefit. . (d) Effective date The amendments made by this section shall apply with respect to widow's insurance benefits and widower's insurance benefits that are payable for months beginning after December 31, 2017. 8. Holding SSI, Medicaid, and CHIP beneficiaries harmless For purposes of determining the income of an individual to establish eligibility for, and the amount of, benefits payable under title XVI of the Social Security Act, eligibility for medical assistance under the State plan under title XIX (or a waiver of such plan), or eligibility for child health assistance under the State child health plan under title XXI (or a waiver of the plan), the amount of any benefit to which the individual is entitled under title II of such Act shall be deemed not to exceed the amount of the benefit that would be determined for such individual under such title as in effect on the day before the date of the enactment of this Act.