I’ve done it both ways depending on the W-2. I report the actual days worked in each location to my company. If they report it to the state and it shows on my W-2, I file for that state. I file everything else in my home state. I figure that the company knows the legal requirements better than I do so I follow their lead.
(Company is a large firm with hundreds of employees that work in multiple states.)