Determining correct state for tax payment and deductions after double relocation

Context:

  1. From beginning of this year I was working for the company A in IL and living in IL. Then in middle of the year I moved to NJ to work for company A only at their NJ site. I quitted from A on date x.
  2. From date x + 1, I started working for another company, say B, in California and moved to California.
  3. Company A sent me final paystub on date x + 4 which included:
    1. Final wages (last few days), $W, for the work I did for A in NJ while living in NJ.
    2. Repayments I had to give back to company A, say $R.
      1. This repayment of $R was of the relocation benefits they gave me for the IL to NJ move. I repaid the entire benefit they gave me (including the commission of the relo management agency).
    3. Payout for unused accrued PTOs at A, say $P.  I accrued PTOs while I was in NJ as well as while in IL (this year only).
 
Question:
  1. To whom do I need to pay the state taxes on the $W. NJ or CA or both?
  2. To whom do I need to pay the state taxes on the $P. NJ or CA or IL or a mix?
  3. Will I get some tax deductions on $R? If so, from which state IL, NJ or CA?

 

Please feel free to reach out for any clarification or if you need more details.