Matt, sorry about a late response, I am retired and working on other projects.
Remove the motor and wire connects to the truck. Also remove both side frames and the motor plate.
You do not have to remove the coupler, the helical gear that meshes with the motor pinion gear is brass.
Look at the drive axle that this gear is attached to, on one end there is a spur gear that drives both geared wheel assemblies.
On the opposite end their is a bearing assembly for this drive shaft. Using a small piece of wood support both wheel axles on the geared side by turning the truck vertical. On the bearing end of the drive shaft I used a nail punch and ball peen hammer to gently tap downward to drive out this shaft. One this shaft moves a fractional distance the spur gear comes out and the helical gear will fall out of the truck block. Clean with alcohol the portion of this shaft and brass helical gear of all grease and oil.
I purchase a small bottle of Loctite 641 retaining compound to bond the helical gear to this drive shaft. I purchased this retaining compound on Amazon or Ebay.
If the teeth on the brass helical gear are not nicked or worn reuse the gear. Frank Timko at Timko's Repair Depot has replacement brass helical gear, I brought some spares from him.
Now the reassembly, hold the brass helical gear in the truck block and slide the shaft from the spur gear into the truck. The brass helical gear should slide easily unto this shaft. Continue pushing this shat in until the spur gear on this shaft meshes with the two integral spur driven wheel gears. Now comes the critical part, center the brass helical gear in the truck block and apply the Loctite 641 retaining compound to the brass helical gear hub bored hole and the shaft. Do this in small amounts using a micro brush, insert a .010-.015 shims both sides of the brass helical hub to prevent the retaining compound from weeping into the truck block to prevent shaft seizure. Once the shim are in place gently slide the helical brass gear left and right and rotate this gear this should help to draw the retaining compound and capillary draw this retaining compound to bond the contact surface of the shaft and brass helical gear hub. Let this assembly bond at least for 24 hours cure time. If the gear breaks free again repeat this total procedure, it failed for me after two months use, the second time I cleaned the axle, brass helical gear and bored hole on the truck both with alcohol and blew it out with compressed air. Contamination of the retaining compound was the issue, these three item must be clean.
This seams like a long procedure, but after the second application, my old Williams Milwaukee Road GP-9 works with no issue pulling 15-20 cars with a caboose on upgrades. For maintenance the Jerry Williams Williams engines that I purchased years ago are very easy to grease and oil.