While serving on board the cruiser USS San Francisco Seaman Second Class Gandy was killed defending the ship against Japanese torpedo planes during the Battle of Guadalcanal.
Gandy headed for the submarine's conning tower but the U-boat's deft maneuvers caused the escort destroyer to hit it 30 feet (9 m) from the stern.
Gandy hauled clear, silenced the submarine's machine gun battery with a short burst of gunfire, then observed the Germans abandoning ship.
Joyce recovered twelve survivors as Gandy, with nearly four feet of her bow strake gone and several plates buckled, assessed her damage.
She departed Pearl Harbor on 6 August 1945 en route to the Philippines via the Marshalls and the Carolines, then sailed from Leyte on the 24th in the escort of an occupation force convoy which entered Tokyo Bay on 1 September.
She departed Samar on 1 February 1946 and reached Norfolk, Virginia, via Hawaii, San Pedro, California, and the Panama Canal, on 26 March 1946.