I heard you say in a lecture to pay charity on behalf of our Imam al Mahdi and his safety and well-being. I started doing that. However I also want to remember my grandmother who passed away recently and pay charity on her behalf but should I pay on behalf of my Imam as that is more important than my grandmother? How to pay charity for both even though they are both not equal as one is infallible and other not just normal person.

Pay charity on behalf of both of them. When you pay charity, you can pay behalf on more than one person. It doesn’t have to be one person only. So first mention Imam Mahdi (a) and then your grandmother.