The ruling overturns a lower-court decision that found Trump was impeding Congress's power to allocate funding.