Definitely a short term vs long term analysis must have been part of the decision.
Short term, it makes them worse since they have no one with the talent of Devers to replace him and it hurts their chances of making the playoffs this season.
However, I doubt they would have made the playoffs this season with Devers. Their pitching is not great. The division is likely out of reach and, while they are in the WC race, I do not see them as consistent enough to beat out their competitors there.
Long term is where the value of this trade works better IMO. I do not believe Devers would have aged well, but now that is SF's problem. The roster and payroll flexibility this gives the Bosox who do have some young prospects they want to play is pretty good, but only if the team is committed to winning and investing that money back into the team. That is a large ? for fans and media here who speculate that ownership is largely distracted (Henry owns several other sports franchises) and the management unproven outside of Alex Cora who has his own baggage to carry around.