The visible coins are part of the problem and an easy fix, coins that have slid through the slot in the ashtray door and are invisible is the rest of the story.
In case anyone else looks here for a solution: My 05 Ram ashtray door has repeated this non latching behavior 3 or 4 times over the years. Each time the culprit has been loose change . First let's set the terminology, the removable tray that holds ashes or coins well call the ashtray. The articulating cubby that holds the ashtray we'll call the door. Step one: remove the ashtray by lifting up and out, then set it aside. Look in the bottom of the door and you will see a slot that allows coins to migrate into the abyss below the door. Enough coins in there and instant latching problems. I bent some wire and fished around in there and really couldn't tell if there were coins this time. Enter: compressed air! As soon as I shot air behind the door it was obvious I had coins in there ... lots of em. Fishing into the abyss through the interior door slot was fruitless so I kept at it with compressed air sending blasts from the top down behind the door and through the gaps outside of the door down low towards the hinge point. My goal was to move the coins where I can see them through the interior door slot and pick them out with a curved pick or wire. As I continually shot air into the lower positions I was focused on seeing coins through the slot when a quarter actually flew out of the abyss through the opening above the door! I kept at it for another few minutes and blew 3 more quarters and some pennies out of there. Case solved! Door latches perfectly again.