Does sunlight damage helmet?
I was able to find one study that comes close to addressing this: Age Does Not Affect the Material Properties of Expanded Polystyrene Liners in Field-Used Bicycle Helmets. You'd need to pay to read the whole thing, but the abstract and title are clear enough. It's not clear from the abstract whether the helmets tested had been exposed to UV or not.

According to the Bicycle Helmet Safety Institute, UV exposure is not a big concern because helmets are treated with UV inhibitors, and unless there's visible signs of cracking, talk of replacing helmets on a regular schedule is marketing hype.

The EPS foam makes up the bulk of the helmet, of course, but it's not the only part, and if the shell, pads, or straps are damaged or degraded, that might be a reason to replace it.