Professor Brier on my “Ancient Egypt” recordings observes that the Egyptians never kept records of a military defeat: they just had “victories” closer and closer to their capital!
Ramses II may have set the record with his great bas relief about the Battle of Kadesh. He was comprehensively out-maneuvered, had his ass kicked, was in grave danger of capture, and when it was clear that the battle was lost, he fled on his chariot, leaving much of his army to be captured and/or slaughtered.
He managed to escape back to Egypt, preparing as well as he could for an invasion that his adversary had no intention of attempting, then they came to an agreement, a treaty that amounted to a mutual non-aggression pact that defined their geographical spheres of influence. Ramses II spent the rest of his very long reign aggrandizing himself with monumental statues, including some made by other pharaohs and modified to look more like himself. Most famously now, KV-5 was rediscovered by Kent Weeks et al, and found to have been the group tomb of Ramses’ sons, perhaps over a hundred.
Meanwhile the Middle East continued to struggle through interdynastic warfare until first the Persian rule, then the Romans, and a series of conquests by different ethnic groups claiming the caliphate.