I have been fixing other peoples problems for about 55 years. This includes everything from septic tanks to decks where the amateur installer overlooked the task of attaching same to house. Your problem is akin to several that I have seen over the years. Outdoor and porch problems used to fill my weekends. Here are my options which could well be wrong as I have not seen your situation.
Removing the plywood sub-floor would be the best way to start if it is nailed to joists or 2x2s. If this works, simply put down a new sub-floor. Check the joists for level if you do this. You can use one inch square shims cut from sheet vinyl (One can easily get a remnant or scrap piece from Home Depot or Lowes.) to place leveling pads about every foot along each joist. Check between joists for level as well. Nail these with common carpet tacks. You should have a perfectly level surface on which to build a new floor on. Before nailing or screwing down the sub floor, glue a sheet of sheet plastic to its bottom side. This will act as a moisture barrier. At this point, you will have a stable base for whatever finish you would want to apply. As a minimum, you should use ¾” B-C grade plywood; A-D will work just as well and is even better if you only plan to paint.
Scraping the sub-floor is the least expensive method. It also requires the most elbow grease. Use a scraper to remove the bulk of the glue and carpet backing. For touch-up, a Surform tool is the cat’s meow. The Surform has an advantage as its blade is replaceable. Fill in any gouges (I use Epoxy paste (PC-7 is an example).) and then you are ready to apply your flooring. Befor actually laying down the new flooring, I would use an fungicide and a paint or stain from Behr, Thompsons or Cabots. The Cabot site is rich with suggestions for both the Do-It-Yourselfer as well as the professional, but I am not acting as an advocate for their products.
A final possibility is to use the vinyl shims, as above, to level and raise a new sub-floor over the old one. In this case, you can use ½ “ plywood as the maximum flex should be less than 1/32“. Level as you would for the joists, but be sure to scrape any crap off where the shims are applied. The shims should be on 16-20” centers. Use the same vapor barrier technique as in the prior option. If this option is used, you run the risk of decay spreading from the original underlayment. A copper based fungicide (look in the garden center) should hold this at bay, but no guarantees. If you do this, keep kids and pets out of the area until the new underlayment is down. The vapor barrier should help with the fungus as well.