Sorry to hear your issue.
The fact of the matter is USCIS is correct. To maintain H1B one should be working and get paid. So even if you were on H1 of "X", since you were not getting paid its considered Out Of Status.
The best thing to do for you is get a good attorney and file a lawsuit...
I would request DHS to Switch I-485 Category to EB-2 (change underlaying approved I-140). That will be the quickest way to get I-485 approved (as its been pending for last three years & must have got Name Check etc cleared)
Apply for EB-2 I-140, once it gets approved, request USCIS to swith the underlaying I-140 of current pending I-485. Its simple process as long as your LC asks for Masters or Bachelors + 5 YR Progressive Exp.