Does that person has a chance to be saved or he/she goes directly to hell like someone in a state of unrepented mortal sin?
If they were in a state of grace that means they repented of whatever it was they had done, right?
Excommunication itself doesn’t mean a person is in a state of mortal sin, even though an excommunicated person might be in a state of mortal sin. Excommunication is a canonical penalty, announced, for instance, when a priest or public figure is causing doctrinal scandal. Whether or not the excommunicated culprit has any impediments to his/her will or understanding of the faith is known ultimately to God and the properly formed conscience.
So the bottom line is, we are not the final judge of souls when they die. Suffice it to say, if that person is in a state of mortal sin at death, then they will go to hell. If not, on to heaven with probably stop in purgatory.
excommunication is a disciplinary measure that does not mean that an excommunicated person is damned to hell.
what happens when an excommunicated dies in state of grace?
Anyone who dies in a state of Grace goes to heaven (with, perhaps, a layover in purgatory). There are NO exceptions.
An excommunication is a judicial act, not a doctrinal act (so it is, in no way, shape, or form, infallible). It has no place whatsoever in the economy of salvation, and it cannot influence our ultimate fate one way or another in any way whatsoever.
If the excommunication was just (meaning I am indeed guilty of mortal sin), and nothing has been done to remediate my sin (such as the oh-so-simple act of attending Sacramental Confession), then I am condemned to hell. But it’s not because of the excommunication - that simply acknowledges what has already condemned me (my sin).
But, if I am not guilty of mortal sin, yet am still excommunicate (perhaps because of a defect in consent or intent which was not apparent to the tribunal which convicted me) then nothing impedes my (eventual) entry into heaven, regardless of the (flawed) excommunication.
St. Joan of Arc died excommunicated and in a state of grace. And went to Heaven.