So far, everyone giving recommendations has failed to mention a crucial detail - which really shows the danger of asking for instructions online from people who don’t know what they’re talking about.
Since the previous joints were soldered, the heat has affected the material properties of the copper, making it extremely soft. Simply cutting the pipe and slipping a new fitting over it without a pipe insert puts you at serious risk of the joint failing catastrophically.
Honestly, I’d just call a plumber. They’ll sort it out in an hour, and you won’t have to wake up in the middle of the night to the sound of your SharkBite flying off and water spraying everywhere.
What I’d do here is cut the pipe at the straight section. You might want to cut off an additional 10-15mm to compensate for the new fitting. Then, to get the pipe inserts to fit into both ends, use a deburring tool to remove the internal lip left by the pipe cutter.
Next, take the nut from a new brass union and slip it over the pipe before joining the two ends back together with a compression connector - don’t use SharkBites. Then just add a new (presumably) 1/2" fiber gasket between the union and the threaded part of your toilet seat(?) and tighten the connection.
The copper pipe itself appears to be 12 mm, so you’ll need a 12 mm compression fitting and a pipe inserts suitable for 12 mm copper or 15 mm PEX.
If it’s for a washing machine, you need a flexible hose instead - since the machine can move during the spin cycle, and a rigid pipe might bend or crack. Here in Finland, building code requires a shut-off valve and a one-way valve after the hose, and those need to be mounted to the wall. That means you’ll need a hammer drill, wall plugs, stainless screws, silicone caulk, and so on. And at that point, you’re already past the cost of hiring a plumber just in tools alone.