Here's why:
* Greeting: If "Hi Mary" is a greeting at the start of a sentence, it generally does not need a comma.
* Example: "Hi Mary, how are you?" (Comma after the greeting)
* Example: "Hi Mary, it's great to see you." (Comma after the greeting)
* Direct Address: If "Hi Mary" is used to directly address someone within a sentence, it does need commas.
* Example: "I'm going to the store, Hi Mary, do you need anything?" (Commas before and after the direct address)
* Example: "Hi Mary, can you please pass me the salt?" (Commas before and after the direct address)
In short: Use your best judgment based on how the phrase is being used in your sentence.