The Catholic Church has supported workers’ rights from Pope Leo XIII’s 1891 encyclical Rerum Novarum to the present day when it comes to defending worker safety and human dignity. Catholic social teaching has never said that people may be forced to join unions or financially support unions, private or public. Such coercion would violate the principle of free association upon which popes from Leo XIII have grounded the right to form and join unions.
What the Supreme Court determined in the Janus v. American Federation of State, County, and Municipal Employees case doesn’t repudiate Catholic social teaching in the least. What it does, however, is rein in public-sector unions that use coerced dues to fund union activities without workers’ consent. Many of these activities include supporting political causes and candidates antithetical to Catholic moral teaching. In my opinion, SCOTUS’s majority ruling was the only correct one.
For further reading, see “Labor unions, yesterday and today,” by Rev. Robert A. Sirico: