The main challenge is that the 2wd 22re motor is not designed to work with a 4wd transfer case. The 4wd transfer case requires a different bellhousing and transmission output shaft than the 2wd transmission. To install the 22re motor in a 4wd truck, you will need to either use a bellhousing and transmission from a 4wd truck or modify the bellhousing and transmission from the 2wd truck to fit the 4wd transfer case.
In addition, you will need to modify the engine mounts and exhaust system to fit the 22re motor in the 4wd truck. The engine mounts from the 2wd truck will not be compatible with the frame of the 4wd truck, and the exhaust system from the 2wd truck will not be long enough to reach the muffler on the 4wd truck.
Overall, it is possible to put a 22re motor from a 2wd Toyota truck into a 4wd truck, but it is not a simple swap and will require some modifications to the vehicle.