Aristotle is well aware that one can act justly towards those with whom one is not friends, even to one's worst enemies. But why should friends not need justice ? Surely I can cheat a friend ? Don't I need justice to check my bad tendencies even towards friends ?
▻ KINDS OF FRIENDSHIP
We need to make two moves to understand Aristotle's views on justice and friendship. The first is that he distinguishes between three kinds of friendship (Nicomachean Ethics,VIII, 1156a7, 1157b) : (1) friendships of pleasure where someone's company - witty, generous, indulgent - is merely but genuinely enjoyable and satisfying; (2) friendships of advantage where an easy relationship is based on mutual advantage as in certain business ties; (3) friendships of virtue where a person is appreciated, valued, and their company sought because one recognises their moral goodness. A person is fine and admirable, a model of good living, and for this reason one wants to be with them and to enjoy them.
It is only to the third kind of friendship that the idea that friends have no need of justice applies. More specifically, it is friendship where there is a mutual recognition of moral goodness.
This is not to say that the third kind of friendship is without pleasure - very far from it. But it does not arise for the sake of pleasure as the first kind of friendship does and it does not produce pleasant incidentally as does the second.
▻ JUSTICE AS A VIRTUE REQUIRING RESTRAINT FROM HARM IS IRRELEVANT BETWEEN FRIENDS
If Aristotle is focusing on friendships based on mutual recognition of moral goodness, it is fairly clear that, in such friendships, restraint from harm is inapplicable since there is no inclination to harm that needs to be restrained or checked. This is brought out in the following passage from John Cooper :
...justice can exist perfectly well among those who care nothing for one
another and who would not lift a finger to help any one else, except insofar
as rules of justice might require. The sense of justice, understood as
respect for fairness and legality, is compatible with a suspicious, narrow,
hard, and unsympathetic character. Hence, as Aristotle says (1155a26-27),
those who are merely just in their mutual relations have need also
of friendship, whereas those who are friends do not need to become
just in addition: since, as friends, they already feel a lively concern
for one another's welfare, they already acknowledge reasons not to
harm or work to disadvantage and can be expected to reach an
accommodation without having to invoke strict rules of justice.
Those who are truly friends will not wrong one another, not, however, out of
love of justice and legality, but from love of one another. (J.M. Cooper,
'Aristotle on the Forms of Friendship', The Review of Metaphysics, Vol. 30,
No. 4 (Jun., 1977), 646.)
▻ JUSTICE AND FRIENDSHIP : A TWIST IN THE ARISTOTELIAN TAIL
Though friends have no need of friendship, Aristotle adds that when a relationship goes wrong and one does act unjustly towards a friend, the injustice is more serious: Cooper, 647.
▻ A QUALIFICATION
Much of Aristotle's language suggests that all three kinds of relationship based respectively on pleasure, utility, and mutual recognition of moral goodness are forms of friendship. But there is at least one passage in the Nicomachean Ethics which suggests that only the third kind is genuine friendship while the others are only approximations to it or similar to it : Nicomachean Ethics, VIII, 1158a19.