The Mets and Brewers had agreed in principle to a trade last July that would send Carlos Gomez back to his original team. Milwaukee officials were so sure this was a done deal that they notified the center fielder’s representatives of the impending swap and went to dinner.

However, in one of the most important decisions not only in Mets history, but in shaping the modern landscape of the game, Mets officials told their Brewers counterparts that their team doctors did not like the look of Gomez’s right hip.

So rather than finalize a swap that would have sent Wilmer Flores and Zack Wheeler to Milwaukee for Gomez, the Mets backed out of the verbal agreement.

In real time, the Mets were hammered for failing to see this to conclusion, in part because word had leaked out and, most famously, Flores cried during the game under the belief he was about to leave the only organization for which he had ever played.

Perhaps the anger of fans and the criticism of media – particularly the sense that the Mets backed out not because of Gomez’s physical problems, but because they did not want to take on his $9 million salary for 2016 – stirred the Mets to make a trade.

Sandy Alderson has insisted that was not a factor, that he was determined to add a significant bat to elevate a putrid offense and better support the wonderful rotation. He tried for Cincinnati’s Jay Bruce and San Diego’s Justin Upton. Those avenues closed. So with the clock ticking toward the July 31 deadline, Alderson dealt Michael Fulmer and Luis Cessa to Detroit for Yoenis Cespedes.

Cespedes’ bat was integral to the Mets winning the NL East en route to the NL title. Had Cespedes never played with the Mets, there is no way they would have continued to monitor his market in the offseason and there is no way he would have pined to figure out a way to stay in New York. He signed a three-year, $75 million contract as a free agent with an opt-out after this season. He is tied for the major league lead in homers (13) and tops the NL in slugging (.649).

Since his Mets debut on Aug. 1, 2015, Cespedes had 30 homers (tied for third-most in the majors), 77 RBIs (sixth), a .620 slugging percentage (second) and a .970 OPS (fifth).

Meanwhile, the Brewers did trade Gomez, on July 30, to the Astros. Since his Houston arrival, Gomez has been among the majors’ worst regulars with a .215 average, four homers and a .588 OPS. Would he have been this bad for the Mets? It is unknown, but it is hard to believe he could have been anywhere near as valuable as Cespedes has been.

While Cespedes thrives again in 2016, Gomez has the lowest OPS (.486) in the AL, to go along with no homers and 46 strikeouts in 121 at-bats. He had lost his starting center field job before being placed on the DL with a ribcage injury. The Astros also got back-end starter Mike Fiers from Milwaukee, but gave up four prospects. One of them, outfielder Domingo Santana, is part of the Brewers team that will face the Mets this weekend for the first time since that scuttled trade.

The two key prospects that Milwaukee received from Houston remain in the minors: outfielder Brett Phillips and power lefty Josh Hader. So the outcome could still get worse for Houston.

And it is pretty bad, right now. After making the playoffs as a wild card last year, the Astros are last in the AL West. There are many reasons for that. But Gomez’s woeful play has been as big as any. The Astros would have been better off if the Mets had completed the trade in principle.

But think about how much worse off the Mets would be if Gomez were with them. Not only would they have him in 2016 – instead of Cespedes – but they also would not have Flores and Wheeler.

And it may turn out that one of the most important parts of the trade that nearly was, but wasn’t, is that the Mets still have Wheeler looming as a helpful rotation piece for the second half this season.