Original: Most of the companies had been transferred to the Army of Northern Virginia to help in the defense of Richmond.
Simplified: Most of the army had been transferred to the Army of Northern Virginia to help in the defense of Richmond.