I'd advocate an engine swap if the Highlander wasn't your primary car. I've swapped motors in two cars (a 1989 Honda Prelude and a 2002 Ford Focus), and while the mechanicals were restored, both times I experienced ongoing electrical gremlins. Engine problem codes primarily, but also some evap system issues, AC problems, and general annoyances. It's very easy to damage the wiring harness or any of the hundreds of electrical connectors and sensors in the engine bay.
I also had an issue with the Honda engine, which was a pull and not a rebuilt motor. While cheap, it developed a leaky cylinder after only a few years, necessitating either a rebuild or another replacement. I wasn't willing to sink another $2000 into a $3000 car. I opted to sell. Maybe I'm just unlucky...
But my point is even an engine replacement involves a roll of the dice.
When my wife's '02 Camry started developing some expensive to repair problems that were leaving us high and dry with increasing regularity after 12 years and 260k miles, we opted to trade on a CPO Highlander, ironically enough. No regrets, as we'd saved 75% of the cost. I'd still shop around for a better rate on the issue, and MAYBE it's not even the problem described. And it's worth looking into an engine swap, but REALLY research shops on this one. It can go VERY wrong and VERY expensive pretty quickly.