The version I heard was that Friendster failed to scale not because of low quality code but because the CEO refused to compromise on a feature that was inherently unscalable.
MySpace was sold to News Corporation for millions, it definitely didn't fail as a startup. There's a point where code quality becomes important, I don't think anyone's denying that, but it's after you've got traction and product-market fit.