The bill was a response to the Supreme Court’s Janus v. AFSCME decision last summer that barred unions from charging nonmembers agency fees. The court ruling undercut a key source of financing for public-sector unions, and the AFL-CIO and other labor leaders have been pressuring the Legislature for over a year to come to their aid.