How did Luke's X-wing fly from Ahch-To? I thought it was damaged beyond repair.
While it's true that Luke's X-Wing is in bad shape (missing part of a wing as well as several other key components), it's worth pointing out that a lot of the major bits that are needed to get it into space, such as repulsorlifts, and the bits that are needed to get it into hyperspace, such as hyperdrive motivators, are housed inside the main body of the ship rather than on the wings. Rey doesn't need to fly it as a combat fighter, she just needs it to limp into orbit and not kill her when she lands at her destination.
It's also worthy of mention that we've seen that exact T-65b X-Wing submerged before and it worked just fine almost straight away afterwards. If anything, seawater would probably less damaging for a piece of fine electronics than swamp ooze.