Installing a membrane flashing under the shingles and over the first metal roofing panel is guaranteed to work.
This picture of a TPO roof is not perfect for the flashing recommendation, the bit should give you some idea of this solution.