Let's denote the number of gray shirts Joanie has as \( g \).
According to the information given:
- The number of black shirts \( b \) is \( 3g + 3 \) (3 times as many black shirts as gray shirts, plus 3 new black shirts).
- The number of white shirts \( w \) is \( 5g - 1 \) (5 times as many white shirts as gray shirts, minus 1 white shirt donated).
- The number of gray shirts \( g \) is \( 2b \) (2 times more gray shirts than brown shirts).
From the problem, we also know that the number of black shirts \( b \) is equal to the number of white shirts \( w \). Therefore, we can set up the equation: \[ b = w \]
Substituting from our expressions for \( b \) and \( w \): \[ 3g + 3 = 5g - 1 \]
Now, let's solve for \( g \):
- Rearrange the equation: \[ 3g + 3 + 1 = 5g \] \[ 4 = 5g - 3g \] \[ 4 = 2g \] \[ g = 2 \]
So Joanie has \( g = 2 \) gray shirts.
Let's find out the numbers of black and white shirts based on \( g = 2 \):
- The number of black shirts: \[ b = 3g + 3 = 3(2) + 3 = 6 + 3 = 9 \]
- The number of white shirts: \[ w = 5g - 1 = 5(2) - 1 = 10 - 1 = 9 \]
Thus, the number of black shirts (9) equals the number of white shirts (9).
Finally, the number of gray shirts Joanie has is \( \boxed{2} \).