It says Vayhi Beshalach Pharoh Es Haam why Vayhi that indicates a language of Tzar what Tzar(pain) is there is Leaving Mitzrayim?
The Ohr HaChayim HaKodosh asks this question and answers that the Jews had alot of Tzaar that Pahroh chased them.
Another answer the Ohr HaChayim HaKodosh says is that Pahroh escorted them out of Mitzrayim. Due to that he would get reward just as Nevochanetzar got rewarded for Sechar Pesiyos.
The Ohr HaChayim HaKodosh has other answers too.
The maskana (conclusion) of the g'mara in M'gila 10:2 is that "vayhi" is not always a term of pain (though "vayhi bime" is).