This paper studies optimal UI policy from the perspective of worker assignment to heterogenous jobs in an environment of random matching. Workers react to UI policy through job acceptance decisions; firms react to UI policy through wage posting. There is endogenous assortative matching as a result of the fact that UI policy induces a time profile for reservation wages, shifting the labor force towards the more productive firms. The relation between productivity dispersion and UI policy is mediated by the wage posting policies of firms that take both productivity and policy into account. Optimal UI policy is shown to crucially depend on the properties of the firm productivity distribution, such as its variance and skewness.