Adding new capacity expansion alternatives using distributed generation (DG) technologies, particularly penetration of renewable energy, has several economical, and technical advantages such as the reduced system costs, the improved voltage profile, lower line loss and enhanced system's reliability. However, the DG units may lead to power quality, energy efficiency, and protection problems in the system when their penetration exceeds a particular value, generally called as the system's hosting capacity (HC) in the literature. In this paper, the HC determination of a distorted distribution system with Photovoltaic (PV)-based DG units is handled as an optimization problem by considering over and under voltage limitations of buses, current carrying capabilities of the lines, and harmonic distortion limitations as constraints. It is seen from simulation results that the HC is dramatically decreased with the increament of the load's nonlinearity level and the utility side's background voltage distortion. Accordingly, a C-type passive filter is designed to maximize the harmonic-constrained HC of the studied system while satisfying the constraints. The results indicate that higher HC level can be achieved using the proposed filter design approach compared to three conventional filter design approaches as voltage total harmonic distortion minimization, line loss minimization and power factor maximization.