It's tricky but it looks like it was shot in a Studio (Green Screen) and that they had a bit of red straw and tiny piles of red sand on the floor.
That's why most of it looks like one Shot, because it is - they neither sang and danced then teleported nor did they dance twice and get that many people in perfect sync and switch from one to the other - they sang and danced the whole thing in a Studio and occasionally a foot would shift the red straw or sand.
The result of the Take in the Studio (with green everywhere, except the aforementioned straw and sand) is them singing and dancing with a floor and background that can be electronically (digitally) removed.
A separate Take is done both at the Beach and the Grass Field without any people present.
Proof is sometimes they kick up the Grass (move the straw underfoot) and sometimes they don't when you'd think that they might have had more occasion to do so - but the straw in the Studio is infrequent and you really need to kick to launch it - plus it's difficult to see.
Final proof is that they don't leave footprints on the sand - that's the clincher that 'wrecks' it.
So you have the Clips of them dancing in the Studio, the Clips of the Beach and Field. Draw Rainbows over the 'Field Clips' and drop the girls on top of that.
Masking is only on the bottom of the Frame, to have Sand or Grass to kick, appear in their respective backgrounds, combined with different takes where the 'kicking up the ground' is more or less pronounced (another thing that 'wrecks' it but harder to notice).
It was neither done cheaply (simply) nor did they spend a fortune (make it complicated). If you knew a dozen chicks you could do this on your Home Computer (assuming reasonable CPU power) using a handheld Video Camera and a bucket of Green Paint (plus some red for the ground effect, or double the number of Takes).
I think they used red as well as green because they don't kick up the ground correctly, much like the background doesn't move properly in relation to them. It was better than moderately well done, but not expertly executed.