The film started out as a project under the supervision of Toby Emmerich and Walter Hamada. Most of the production was done under their watch. The original ending for The Flash was for Barry Allen to meet Supergirl (Sasha Calle) and Batman (Michael Keaton). The ending was supposed to reverse the death of Batman and Supergirl from earlier in the movie and signifies that The Flash didn't manage to alter the timeline as he thought he did.
The movie was caught up in Discovery's acquisition of Warner Bros in 2022. Hamada and Emmerich departed the company and Michael De Luca and Pamela Abdy were tasked with overseeing DC while Warner Bros Discovery CEO David Zaslav was searching for a permanent replacement.
De Luca and Abdy came up with a new ending for The Flash, one where Calle's Supergirl is joined by the rest of Zack Snyder's Justice League, including Henry Cavill's Superman, and Gal Gadot's Wonder Woman. The ending was meant to tease audiences for a new Man of Steel movie and Wonder Woman 3, as well as tease the Crisis on Infinite Earths story arc that was part of a ten-year plan for DC that spanned multiple projects.
The initial goal was to use the film to help solidify that Cavill had returned as Superman to the DCEU after the Black Adam cameo with Patty Jenkins' third Wonder Woman movie with Gal Gadot helping with this.