We can pray for persons who have committed mortal sin.
That passage in Scripture means that if you pray for someone who has committed a venial sin, that person can be forgiven without confession. But as for mortal sin, they cannot be forgiven without repentance and confession (or perfect contrition). It means that you should not expect someone who commits an actual mortal sin to be forgiven by your prayer alone, but only if they respond to God's grace. Whereas for venial sin, even if someone does not specifically consciously repent from a venial sin, they can still be forgiven by your prayer.