I have edited this post as I realised afterwards that I left my answer incomplete. In western music the A minor scale has three variants:
Natural minor - A - B - C - D - E - F -G -A
Harmonic minor - A -B - C -D - E - F - G# - A
Melodic minor - A - B - C - D - E - F# -G# - A
Generally the melodic minor scale is used in a ascent of the notes and a D major works. But what we are missing here, and what I should have explained earlier, is that when working on chord progression you are not stuck to the notes/chords of that scale. You can āborrowā chords from related scales.
For example in A minor you can borrow from the A major scale. So this opens the door to playing any chord that contains the notes C#, F# and G#. D major contains D F# and A, and is the subdominant of the key of A Major. Similarly E G# B, although appears in the harmonic minor scale you can look on it as the dominant of the Major scale.
Therefore, you can use the major IV chord when you are in any minor key and any minor IV chord when you are playing in the major key.
Trust this helps.