I ran a 340h behind a 5vz using the 99 ecu on an unmodified 3rd gen engine harness. Swapped the speed sensor, solenoid harness, and park neutral switch from a 99 340f. Took me all of 30min to swap over. No codes. Shifted great. I even think I ran the 340f tc on the 340h.
Difference between a prior to 01 and after 01 is the kick down cable. To avoid that hurdle. just grab a 340f from a sequoia or tundra or grab a drill or plug. But if you want a straight direct bolt without having to touch a thing, then your only option is the 01-02.
That being said, I personally would not buy a used transmission that has been sitting in the junkyard for a while unless you have another DD. But I have heard of people who have and not had issues. But then there are the one who did have issues. I suggest looking into a reputable shop that rebuilds transmissions or spend the money for a reman.
I had mine rebuilt after I picked up my 99 when when the previous own had the strawberry milkshake. I have put over a 100k on it since and still shifts strong.