The court ruling is the latest in a weeks-long legal battle over the fate of the nation’s largest public initiative to combat hunger.