First of all Raj extension based on the present company, Raj extension is limited only to company A. If Raj wants to move to Company B, he has to have had the I-140 still “alive” when the H1B transfer is approved because both extension and H1B transfer require that either you have an approved I-140 (AC21 104(c)) or a pending labor of 365 days (AC 21 106(c)). See AC 21 memo 2008

Basically Raj will no longer be Cap-Exempt under AC 21 because he no longer have an approved I-140 under AC 21 104(c) or a pending labor of 365 days AC 21 106(c). The USCIS, in fact, treats both H1B extension and H1B transfer as the same issue. As such Raj might well not be able to work for Company B because his H1B transfer will probably be denied. If Company A has not withdrawn Raj’s H1B petition, Raj can still move back to Company A and work for two more years. But if Company A did withdraw the H1B, Raj will have no choice than to leave the United States, or move to some sort of other visas.

This is a very delicate situation which can also affect H4 visa holders and their EADs. If you are in a scenario above you should make sure that your H1B transfer is approved first then move to company B. However, there might be other problems looming in the vicinity if you are transferring while the I-140 is withdrawn.