Relevant Linear issue here. D4717 was my original code to fix this, but it ended up breaking yarn react-native run-android.
Turns out the problematic code was writing if [[ ! $found ]] instead of if [[ "$found" = false ]] since in bash ! returns true for any nonempty string (and found is nonempty even when it's equal to false). Once I changed that, yarn react-native run-android builds successfully.