Pip's greatest mistake was with Joe. Pip realizes how good Joe was to him all through his life, even when he was ashamed of Joe. Joe cared for Pip when he needed someone to help him get his health back. Joe even paid for all of Pip's debts. Although Pip would pay him back, he would always regret how he treated Joe. Joe was never educated, and never needed to be. Pip became aloof and distant once he realized he was upper class and educated.
Although he doesn't lose Joe's friendship, he lost the innocent and wonderful relationship they had. He'll never quite have that back, but the two of them do keep in touch and Joe and Biddy name their child after Pip. So it does end happily in that aspect.