That's a mess.
Options to fix it properly in a way that won't cause more trouble later are to cut off the fitting at the wall, use a hub-saver (example) to clean the old pipe out of the glued fittings, and glue in a longer section of pipe. You have to allow (as whoever glued this up evidently did not, unless this is a new sink without the outlet in a different place than the old one) for the pipe going further into the fittings when glued than it does when dry-fit.
Or do the same thing but instead of a longer piece of pipe, cut the trap slip-fit adapter and a short piece of the pipe from the upper end of this glued trap and glue that into the hub you clean out at the wall, then use a slip-fit trap you can actually adjust.