the flush is dangerous because most goons who do it reverse flow.... that knocks material out of nooks and crannies and introduces them into the flow again, and it usually ends up in valve bodies and solenoids- either of which is no bueno.
if you wanted to flush is properly, you'd have to find a shop that uses a heated flush machine and dials pressure to that of the transmission- heated so the entire circuit gets flushed... it's uncommon that folks at shops take the time or have the interest in doing the job right.
o/d flashing is the transmissions way of telling you it has an issue- it doesn't mean it's overhaul time, though i don't think i've ever encountered a transmission shop who didn't turn to "overhaul" as the first option... there is a lot of witchcraft and black magic in those things, and shops leverage that for gain at your expense.
your p0731 is a ratio code- meaning the transmission can't shift into first gear... because it is solo, it means the electrical points are checking out but it just won't shift. so... drop your shift lever to 1st and see if it engages firmly. does it? then it's likely a solenoid that is causing your grief. does it not? you likely have band issues- first thing to try is a simple band adjustment.
not to reverse course on my prior comments, but bands needing adjustment demonstrates wear and weakness- and if it is a band issue, then there are other things that are about to happen. you can buy several thousand or even tens of thousands of miles by carefully adjusting the bands. follow the instructions to the letter.
solenoid packs aren't exactly cheap, but they're hella better than overhauling. they can cause issues if not recovered. if there is a lot of sluff (clutch material) in the fluid/pan and on the magnet, then it stands to chance the solenoids are holding a fair amount, too.
determine your issue- if it's mechanical or electrical by following the two simple steps above: again, though: drop the trans using the gear shifter into first- does it bite and engage without complaint? then it's likely a solenoid... does it not? it is likely a band...
then drain drop pan adjust band and swap solenoid...
then refill with fresh fluid.......... if you want, do a redneck flush, which cost some coin due to the price of fluid, but get three gallons of juice.. warm the transmission to operating temperature... open them up and stage the juice within reach of the fill tube, and a funnel in the tube... disconnect the RETURN line from cooler and point it into a bucket- use extra hose if you have to... have a partner sitting in the drivers seat and fire her up- pour fluid in at the same rate of discharge... have them shift slowly through the gears with their foot firmly on the brake (wouldn't hurt to engage parking brake and chock wheels)... keep pouring/collecting until you've spent two gallons (discharge should look fresh at this point).... kill engine, reconnect return line to transmission... top her off with the third gallon (won't use a lot of it).... drive for a week or so (say, a thousand miles), and drain pan refill fresh.... those lines and that trans is likely now as clean as any machine would make it.
DON'T overfill... ATF expands tremendously. you'll want to aim for the cold fill line top even on a transmission that is 'operating temperature'. when that transmission goes to work and heats that stuff up it'll expand on into the 'hot fill' area with ease.