For example, the vehicle manufacturers in this country spent decades telling people that their warranty would be void unless they returned their cars to the dealership for servicing and repairs. They knocked back countless warranty claims based on no other reason but the fact that servicing and repairs were done elsewhere. And then someone took it to court, the ACCC got involved, and the manufacturers were told in no uncertain terms that their policy was illegal and uncompetitive. Now it is industry-wide knowledge that an owner can get their vehicles serviced wherever the hell they choose, as long as the mechanic is qualified and the repair is up to OEM spec.
Apple refusing to honour a valid warranty claim because a previous repair was done elsewhere is anti-competitive and almost certainly illegal. They can assert whatever policy they want, but if a consumer needs a repair that isn't covered by warranty, they have the legal right to spend their money where they see fit. As long as the work is completed to OEM specifications, there is no justification for such repairs to affect the OEM warranty. Even if it isn't done to OEM specs, unless it caused the new issue and the deficiency of the old repair doesn't impede the new repair they still don't have justification.
This has been confirmed by the courts and the ACCC on many occasions in many different industries. If someone filed a claim against Apple because of something like this, I would be shocked if Apple was successful. Most likely, they'd fix or replace it quietly just to shut you up. There's no way they'd want this tested in court for the sake of a couple of hundred bucks.