Endings are predetermined.
Traditionally most wrestling matches are not rehearsed extensively in advance, they go over the ending, the general flow/story of the match, and a few big moments and then improvise the rest of the match in the ring based on what is and isn't working and the crowd reaction.
If two wrestlers haven't worked together before they'd go over any particular/unusual moves they use and how to bump (protect yourself) for them. In WWE there's usually an agent (a former wrestler) who helps them communicate before the show and figure things out. For the most part once you know the basics of wrestling you can take most moves with just a few descriptors of the set up and the bump. Some more advanced sequences might require some sort of preshow walk through or rehearsal, but you don't have to have those in a match, particularly in a TV match, which tends to be shorter.
One wrestler has the "call", usually whoever is working as the heel (villain) but sometimes the wrestler with the most experience and tells the other what moves to do next while the match is going on. Rarely (if both wrestlers are inexperienced) the Ref might be the one to call the match.
Some wrestlers did prefer to more extensively plan out their matches beforehand, and sometimes even rehearse the entire match for the biggest show. Macho Man Randy Savage and Diamond Dallas Page were two of the bigger stars who liked to do this, but they were an exception.
In recent years it's gotten a bit more complicated, NXT (the training league) has a much lighter schedule and is known for more extensively planning out matches and sometimes rehearsing it or at least certain sequences in the match, with the help of one of the agents/trainers. Then wrestlers would get to the main WWE roster and be expected to adjust to the traditional formula of a less planned out match, which would lead to issues.
WWE in recent years has indeed become known for sudden changes of direction, wrestlers being called up or shifted to another show with little notice and match results being decided or changed the day of the show.
IRL Paige says she was told she was being called up and was winning the day before the show. It wouldn't be unusual for her to have not told her family she was going to win, either to protect against it leaking or in case it was changed at the last minute.