I spent two nights in Flam because I really wanted to see the Borgund stave church, and public transportation necessitated being in Flam for a full day. Otherwise, one night would have been enough to break up the trip and avoid the need to start out with a really early departure from Oslo. With one night in the fjord area, Flam is the easiest place to stay, and the setting is beautiful (though the town itself is plain, and there may be a large cruise ship in port). It seems that Aurland also works, though I'm not sure anyone on this forum has stayed there.
Lodging in Flam is really, really tight. I'd recommend investigating the options, of which most or all are probably on booking.com for easy reference. Prioritize them so you're ready to reserve something (cancellable) as soon as you know your travel dates. You can do the actual booking directly with the hotel. Unless you want to be scrambling, this needs to be done way, way ahead of time--and I don't just mean in April or May. I have no idea when would be early enough; 2022 wasn't as busy a year for travel as what we're now experiencing, and I think I booked in January for July. At that point, there was almost nothing available. I ended up in a very plain private room at the youth hostel, and I was lucky to get it.
There's some really nice scenery between Oslo and Myrdal, so unless you don't care at all about seeing Oslo (nice city) and can fly straight into Bergen, I don't see any advantage to flying to Bergen and doing an out-and-back fjord trip from there. You'd be missing some nice scenery and not saving a worthwhile amount of money.
I don't know anything about the frequency of the various transportation legs you'd need to arrange if you wanted to see the Geirangerfjord instead. This would be a good time to dig into September schedules.