How do I set up this Chi Square Test of Independence?

Here's the problem I'm working with:

"During economic downturns corporations may undertake a “reduction in force,” known as an RIF, in which substantial numbers of employees are laid off. Federal and state laws require that employees over the age of 40 years are a “protected class.” Many allegations of discrimination focus on comparing employees over 40 with their younger coworkers.

Consider a company employing 1317 workers. During a recent RIF for this company, 7 of the 511 employees who were 40 years old or younger were laid off while 41 of the 806 employees who were over 40 years old were laid off.

Appropriate analysis of this data revealed that a disproportionately high number of employees over 40 years old were laid off during the RIF than would be expected if age was irrelevant to the lay-off/do-not-layoff decision. (P-value = 0.0005!)

But, while some would be quick to claim discrimination, is this necessarily evidence of discrimination? For instance, a major issue that arises in RIF’s like this one is the extent to which employees in various groups are similar. If, for example, employees over 40 generally received lower performance ratings than the younger workers, it might explain why more of the older employees were laid off. The possible appraisal results included “partially meets expectations,” “fully meets expectations,” “usually exceeds expectations,” and “continually exceeds expectations.” Because there were very few employees for whom the appraisal was “partially meets expectations,” those who earned “partially meets expectations” and “fully meets expectations” were combined. Perform an appropriate analysis of the data to determine if performance appraisal helps explain why relatively more of the older employees were laid off. (Note: The total number of employees in the data file is less than 1317 because some employees did not have a performance appraisal.)"

So the above shows the data I was given about the performance evaluation and the contingency table I've set up. My question is, where do I go from here?

I know from the problem we have two population proportions that I've defined as:

p1= employees under the age of 40 who were laid off = 7/511

and

p2 = employees over the age of 40 who were laid off = 41/806.

Where exactly do I go from here? How do I relate p1 and p2 to the data about the performance evaluations

Re: How do I set up this Chi Square Test of Independence?

Remember for this test, you are looking for differences between observed and expected values.

You have your observed values and your categories (Laid Off, Age) which yields a 2x2 contingency table/matrix like the attached image. From here, you should be able to calculate the expected values and then calculate the Chi-square value (and subsequent p value).