In this reaction anion of phthalamide is the nucleophile. Potassium salt of pthalamide is ionic and the anion readily attacks R-X which has to be primary or secondary. The reaction is SN2.
2nd step: Hydrolysis gives primary amine and phthalic acid.
What are the reagents in this 'hydrazinolosis' you mentioned?